Browse Source

format cleaning

shuvit 6 years ago
parent
commit
5edf0fac1f
1 changed files with 30 additions and 35 deletions
  1. 30
    35
      joy_cam.py

+ 30
- 35
joy_cam.py View File

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

Loading…
Cancel
Save