Parcourir la source

format cleaning

shuvit il y a 6 ans
Parent
révision
5edf0fac1f
1 fichiers modifiés avec 30 ajouts et 35 suppressions
  1. 30
    35
      joy_cam.py

+ 30
- 35
joy_cam.py Voir le fichier

1
-import bge
1
+################################################
2
+#joystick flythrough camera for scene testing  #
3
+#shuvit.org                                    #
4
+################################################
2
 
5
 
6
+import bge
3
 
7
 
4
 def main():
8
 def main():
5
-
9
+#####
10
+    #init
6
     cont = bge.logic.getCurrentController()
11
     cont = bge.logic.getCurrentController()
7
     own = cont.owner
12
     own = cont.owner
8
-    
9
-    aXis = cont.sensors['stickDirections']
10
-    
13
+    aXis = cont.sensors['stickDirections'] 
11
     reduction = 400000
14
     reduction = 400000
12
     axisTh = 0.03 
15
     axisTh = 0.03 
13
-    
16
+
17
+#####
18
+    #hard controller mappings    
14
     lar_lts = 0
19
     lar_lts = 0
15
     uad_lts = 1
20
     uad_lts = 1
16
     lar_rts = 2 
21
     lar_rts = 2 
17
     uad_rts = 3 
22
     uad_rts = 3 
18
     lt = 4 
23
     lt = 4 
19
     rt = 5  
24
     rt = 5  
20
-
21
     a_but = 0 
25
     a_but = 0 
22
     b_but = 1 
26
     b_but = 1 
23
     x_but = 2 
27
     x_but = 2 
33
     r_dp = 14 
37
     r_dp = 14 
34
     u_dp = 11 
38
     u_dp = 11 
35
     d_dp = 12 
39
     d_dp = 12 
36
-    
40
+
41
+    reduction = 400000
42
+    axisTh = 0.03    
43
+
44
+#####
45
+    #get value 0-100    
37
     lLR = aXis.axisValues[lar_lts] / reduction / .082 * 100
46
     lLR = aXis.axisValues[lar_lts] / reduction / .082 * 100
47
+    lUD = aXis.axisValues[uad_lts] / reduction / .082 * 100 - 20 / 80
48
+    rLR = aXis.axisValues[lar_rts] / reduction / .082 * 100 - 20 / 80
49
+    rUD = aXis.axisValues[uad_rts] / reduction / .082 * 100 - 20 / 80
50
+    lTrig = aXis.axisValues[lt] / reduction / .082 * 100 - 20 / 80
51
+    rTrig = aXis.axisValues[rt] / reduction / .082 * 100 - 20 / 80
52
+
53
+#####
54
+    #create modified axis values
38
     if lLR < -20:
55
     if lLR < -20:
39
         lmLR = round((lLR + 20) / 80 * 100, 0) 
56
         lmLR = round((lLR + 20) / 80 * 100, 0) 
40
     elif lLR > 20:
57
     elif lLR > 20:
41
         lmLR = round((lLR - 20) / 80 * 100, 0)
58
         lmLR = round((lLR - 20) / 80 * 100, 0)
42
     else: lmLR = 0  
59
     else: lmLR = 0  
43
           
60
           
44
-    lUD = aXis.axisValues[uad_lts] / reduction / .082 * 100 - 20 / 80
45
     if lUD > 20:
61
     if lUD > 20:
46
         lmUD = round((lUD - 20) / 80 * 100, 0)
62
         lmUD = round((lUD - 20) / 80 * 100, 0)
47
     elif lUD < -20:
63
     elif lUD < -20:
48
         lmUD = round((lUD + 20) / 80 * 100, 0)
64
         lmUD = round((lUD + 20) / 80 * 100, 0)
49
     else: lmUD = 0 
65
     else: lmUD = 0 
50
-    #lmUD = lmUD * -1
51
-           
52
-    rLR = aXis.axisValues[lar_rts] / reduction / .082 * 100 - 20 / 80
66
+
53
     if rLR < -20:
67
     if rLR < -20:
54
         rmLR = round((rLR + 20) / 80 * 100, 0)
68
         rmLR = round((rLR + 20) / 80 * 100, 0)
55
     elif rLR > 20:
69
     elif rLR > 20:
56
         rmLR = round((rLR - 20) / 80 * 100, 0)
70
         rmLR = round((rLR - 20) / 80 * 100, 0)
57
-    else: rmLR = 0  
58
-       
59
-    rUD = aXis.axisValues[uad_rts] / reduction / .082 * 100 - 20 / 80
71
+    else: rmLR = 0         
72
+    
60
     if rUD > 20:
73
     if rUD > 20:
61
         rmUD = round((rUD - 20) / 80 * 100, 0)
74
         rmUD = round((rUD - 20) / 80 * 100, 0)
62
     elif rUD < -20:
75
     elif rUD < -20:
63
         rmUD = round((rUD + 20) / 80 * 100, 0)
76
         rmUD = round((rUD + 20) / 80 * 100, 0)
64
     else: rmUD = 0 
77
     else: rmUD = 0 
65
-    #rmUD = rmUD * -1
66
-        
67
-    lTrig = aXis.axisValues[lt] / reduction / .082 * 100 - 20 / 80
68
-    rTrig = aXis.axisValues[rt] / reduction / .082 * 100 - 20 / 80    
69
-
70
-    #sens = cont.sensors['stickDirections']
71
-
72
-    
73
-    
78
+  
74
     if lTrig > 3:
79
     if lTrig > 3:
75
         mTrig = lTrig * -1
80
         mTrig = lTrig * -1
76
     elif rTrig > 3:
81
     elif rTrig > 3:
77
         mTrig = rTrig    
82
         mTrig = rTrig    
78
     else: mTrig = 0
83
     else: mTrig = 0
79
-    #print(lmTrig)
80
-    
81
 
84
 
82
     #move camera
85
     #move camera
83
     damping = .95
86
     damping = .95
94
     if move_x == 0 and own['last_move_x'] != 0:
97
     if move_x == 0 and own['last_move_x'] != 0:
95
         move_x = own['last_move_x'] * damping
98
         move_x = own['last_move_x'] * damping
96
     if move_y == 0 and own['last_move_y'] != 0:
99
     if move_y == 0 and own['last_move_y'] != 0:
97
-        move_y = own['last_move_y'] * damping        
98
-    #if move_x > 0:
99
-    #if own['last_move_x'] < 0 and move_x > own['last_move_x']:
100
-    #    move_x = own['last_move_x'] * damping        
101
-    #else:
102
-        #move_x = own['last_move_x'] * damping2    
103
- 
104
-    #elif move_x < -1 and move_x > own['last_move_x']:
105
-        #move_x = own['last_move_x'] * damping            
100
+        move_y = own['last_move_y'] * damping                  
106
     
101
     
107
     move = [move_y, 0, move_x]
102
     move = [move_y, 0, move_x]
108
     own.applyMovement( move, True)
103
     own.applyMovement( move, True)

Loading…
Annuler
Enregistrer