|
@@ -0,0 +1,123 @@
|
|
1
|
+import bge
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+def main():
|
|
5
|
+
|
|
6
|
+ cont = bge.logic.getCurrentController()
|
|
7
|
+ own = cont.owner
|
|
8
|
+
|
|
9
|
+ aXis = cont.sensors['stickDirections']
|
|
10
|
+
|
|
11
|
+ reduction = 400000
|
|
12
|
+ axisTh = 0.03
|
|
13
|
+
|
|
14
|
+ lar_lts = 0
|
|
15
|
+ uad_lts = 1
|
|
16
|
+ lar_rts = 2
|
|
17
|
+ uad_rts = 3
|
|
18
|
+ lt = 4
|
|
19
|
+ rt = 5
|
|
20
|
+
|
|
21
|
+ a_but = 0
|
|
22
|
+ b_but = 1
|
|
23
|
+ x_but = 2
|
|
24
|
+ y_but = 3
|
|
25
|
+ l_bump = 9
|
|
26
|
+ r_bump = 10
|
|
27
|
+ bk_but = 4
|
|
28
|
+ st_but = 6
|
|
29
|
+ xb_but = 5
|
|
30
|
+ lts_pr = 7
|
|
31
|
+ rts_pr = 8
|
|
32
|
+ l_dp = 13
|
|
33
|
+ r_dp = 14
|
|
34
|
+ u_dp = 11
|
|
35
|
+ d_dp = 12
|
|
36
|
+
|
|
37
|
+ lLR = aXis.axisValues[lar_lts] / reduction / .082 * 100
|
|
38
|
+ if lLR < -20:
|
|
39
|
+ lmLR = round((lLR + 20) / 80 * 100, 0)
|
|
40
|
+ elif lLR > 20:
|
|
41
|
+ lmLR = round((lLR - 20) / 80 * 100, 0)
|
|
42
|
+ else: lmLR = 0
|
|
43
|
+
|
|
44
|
+ lUD = aXis.axisValues[uad_lts] / reduction / .082 * 100 - 20 / 80
|
|
45
|
+ if lUD > 20:
|
|
46
|
+ lmUD = round((lUD - 20) / 80 * 100, 0)
|
|
47
|
+ elif lUD < -20:
|
|
48
|
+ lmUD = round((lUD + 20) / 80 * 100, 0)
|
|
49
|
+ else: lmUD = 0
|
|
50
|
+ #lmUD = lmUD * -1
|
|
51
|
+
|
|
52
|
+ rLR = aXis.axisValues[lar_rts] / reduction / .082 * 100 - 20 / 80
|
|
53
|
+ if rLR < -20:
|
|
54
|
+ rmLR = round((rLR + 20) / 80 * 100, 0)
|
|
55
|
+ elif rLR > 20:
|
|
56
|
+ rmLR = round((rLR - 20) / 80 * 100, 0)
|
|
57
|
+ else: rmLR = 0
|
|
58
|
+
|
|
59
|
+ rUD = aXis.axisValues[uad_rts] / reduction / .082 * 100 - 20 / 80
|
|
60
|
+ if rUD > 20:
|
|
61
|
+ rmUD = round((rUD - 20) / 80 * 100, 0)
|
|
62
|
+ elif rUD < -20:
|
|
63
|
+ rmUD = round((rUD + 20) / 80 * 100, 0)
|
|
64
|
+ 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
|
+
|
|
74
|
+ if lTrig > 3:
|
|
75
|
+ mTrig = lTrig * -1
|
|
76
|
+ elif rTrig > 3:
|
|
77
|
+ mTrig = rTrig
|
|
78
|
+ else: mTrig = 0
|
|
79
|
+ #print(lmTrig)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+ #move camera
|
|
83
|
+ damping = .95
|
|
84
|
+ damping2 = 1.005
|
|
85
|
+ mult = .0005
|
|
86
|
+ move_x = lmUD * mult
|
|
87
|
+ move_y = lmLR * mult
|
|
88
|
+ move_z = (mTrig * -mult) / 4
|
|
89
|
+
|
|
90
|
+ rot_mult = -.00005
|
|
91
|
+ rot_x = rmUD * rot_mult
|
|
92
|
+ rot_y = rmLR * rot_mult
|
|
93
|
+
|
|
94
|
+ if move_x == 0 and own['last_move_x'] != 0:
|
|
95
|
+ move_x = own['last_move_x'] * damping
|
|
96
|
+ 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
|
|
106
|
+
|
|
107
|
+ move = [move_y, 0, move_x]
|
|
108
|
+ own.applyMovement( move, True)
|
|
109
|
+ own.applyMovement([0, 0, move_z], False)
|
|
110
|
+ own.applyRotation([rot_x, 0, 0],True)
|
|
111
|
+ own.applyRotation([0, 0, rot_y],False)
|
|
112
|
+
|
|
113
|
+ own['lmLR'] = lmLR
|
|
114
|
+ own['lmUD'] = lmUD
|
|
115
|
+ own['rmLR'] = rmLR
|
|
116
|
+ own['rmUD'] = rmUD
|
|
117
|
+ own['mTrig'] = mTrig
|
|
118
|
+ own['last_move_x'] = move_x
|
|
119
|
+ own['last_move_y'] = move_y
|
|
120
|
+ print(move_x)
|
|
121
|
+
|
|
122
|
+main()
|
|
123
|
+
|