Browse Source

walk cleanup

shuvit 6 years ago
parent
commit
dc43aec0da
1 changed files with 19 additions and 226 deletions
  1. 19
    226
      walk.py

+ 19
- 226
walk.py View File

@@ -1,9 +1,6 @@
1
-#os = 'Windows'
2
-#from sys import platform
3
-#if platform != "win32":
4
- #os = 'Linux'
5
-def onWindows():
6
- return os == 'Windows'
1
+#shuvit.org
2
+#walk.py
3
+
7 4
 import bge
8 5
 import GameLogic
9 6
 import ctypes
@@ -15,35 +12,6 @@ import math
15 12
 scene = bge.logic.getCurrentScene()
16 13
 objList = scene.objects
17 14
 
18
-#reduction = 400000
19
-#axisTh = 0.03 
20
-
21
-############
22
-##vibration#
23
-############
24
-## Define necessary structures
25
-#class XINPUT_VIBRATION(ctypes.Structure):
26
-#    _fields_ = [("wLeftMotorSpeed", ctypes.c_ushort), ("wRightMotorSpeed", ctypes.c_ushort)]
27
-#xinput = ctypes.windll.xinput1_3 # Load Xinput.dll
28
-## Set up function argument types and return type
29
-#XInputSetState = xinput.XInputSetState
30
-#XInputSetState.argtypes = [ctypes.c_uint, ctypes.POINTER(XINPUT_VIBRATION)]
31
-#XInputSetState.restype = ctypes.c_uint
32
-## Now we're ready to call it. Set left motor to 100%, right motor to 50%
33
-## for controller 0
34
-##vibration = XINPUT_VIBRATION(65535, 32768)
35
-##XInputSetState(0, ctypes.byref(vibration))
36
-## You can also create a helper function like this:
37
-#def set_vibration(controller, left_motor, right_motor):
38
-#    vibration = XINPUT_VIBRATION(int(left_motor * 65535), int(right_motor * 65535))
39
-#    XInputSetState(controller, ctypes.byref(vibration))  
40
-## ... and use it like so
41
-##set_vibration(0, 0.2, 0.2)
42
-################
43
-##end vibration#
44
-################
45
-
46
-
47 15
 cont = GameLogic.getCurrentController() 
48 16
 obj = bge.logic.getCurrentScene().objects
49 17
 char = bge.constraints.getCharacter
@@ -51,9 +19,6 @@ own = cont.owner
51 19
 stance = own['stance']
52 20
 STANCE = own['stance']
53 21
 r_ground = cont.sensors["r_Ground"]
54
-#Sensor logic bricks connected to the python Controller  
55
-#aXis = cont.sensors["sControla.001"]
56
-#bUtt = cont.sensors["sControlb.001"]
57 22
 linvel = own.getLinearVelocity(True)
58 23
 lasta = own['lasta']
59 24
 lastx = own['lastx']
@@ -68,32 +33,6 @@ except:
68 33
 truckon = 30
69 34
 deckon = 30
70 35
 
71
-#onW = onWindows()
72
-
73
-# windows stuff
74
-#lar_lts = 0
75
-#uad_lts = 1
76
-#lt = 4 if onW else 2
77
-#lar_rts = 2 if onW else 3
78
-#uad_rts = 3 if onW else 4
79
-#rt = 5
80
-
81
-#a_but = 0 if onW else 0
82
-#b_but = 1 if onW else 1
83
-#x_but = 2 if onW else 2
84
-#y_but = 3 if onW else 3
85
-#l_bump = 9 if onW else 4
86
-#r_bump = 10 if onW else 5
87
-#bk_but = 4 if onW else 6
88
-#st_but = 6 if onW else 7
89
-#xb_but = 5 if onW else 8
90
-#lts_pr = 7 if onW else 9
91
-#rts_pr = 8 if onW else 10
92
-#l_dp = 13 if onW else 11
93
-#r_dp = 14 if onW else 12
94
-#u_dp = 11 if onW else 13
95
-#d_dp = 12 if onW else 14
96
-
97 36
 lLR = dict['lLR']
98 37
 lUD = dict['lUD']
99 38
 rLR = dict['rLR']
@@ -121,16 +60,6 @@ sens = .04
121 60
 fliplay = 30
122 61
 dropinCol = own.sensors['dropinCol']
123 62
 
124
-#no input
125
-#def cutOff():
126
-#    
127
-# if (abs(lLR) < axisTh 
128
-#     and abs(lUD) < axisTh 
129
-#     and abs(rLR) < axisTh 
130
-#     and abs(rUD) < axisTh
131
-#     and aBut == False):
132
-#         
133
-#  return True
134 63
 skater = scene.objects["Char4"]
135 64
 deck = scene.objects["deck"]
136 65
 trucks = scene.objects["trucks"]
@@ -174,7 +103,6 @@ def trucksisplaying():
174 103
     for x in range(5000):
175 104
         if deck.isPlayingAction(x):
176 105
             print("deck is playing:", x)
177
-#trucksisplaying() 
178 106
 
179 107
 def printplaying():
180 108
     splaying_layers = "S: "
@@ -204,42 +132,18 @@ if r_ground.positive and xBut == False and lastx == False:
204 132
     #killact(11)
205 133
     killact(12)
206 134
     killact(13)              
207
-######################################  
208
-#walk out
209
-#print(own['walk_timer'])
210
-#if own['walk_timer'] < 5:
211
-#    
212
-#    if stance == 0 and skater.isPlayingAction(fliplay) == False:
213
-#        
214
-#        if own['throw_deck'] == True:
215
-#            print("walk out1")
216
-#            skater.playAction("reg_nwalk_nb.001", 15,35, layer=29, play_mode=0, speed=.5)
217
-#        else:
218
-#            print("walk out2")
219
-#            skater.playAction("walk.000", 15,35, layer=29, play_mode=0, speed=.5)
220
-#        deck.playAction("a_reg_walk", 0,35, layer=17, play_mode=0)
221
-#        trucks.playAction("a_reg_walk", 0,35, layer=17, play_mode=0)    
222
-    
135
+######################################    
223 136
 
224 137
 #idle      
225 138
 if stance == 0 and skater.isPlayingAction(fliplay) == False and yBut == False and r_ground.triggered and xBut == False and noidle == 0 and own['walk_idling'] == 0 and own['sit'] == 0 and own['dropinTimer'] == 0 and own['lasty']  == False:
226 139
     own['requestAction'] = 'reg_idle'
227 140
     if own['throw_deck'] == True:
228 141
         own['requestAction'] = 'reg_idle_nb'
229
-        #skater.playAction("reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
230
-    #else:
231
-        #skater.playAction("reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
232
-        #deck.playAction("a_reg_idle1", 1,120, layer=3, play_mode=1, speed=.5)
233
-        #trucks.playAction("a_reg_idle1", 1,120, layer=3, play_mode=1, speed=.5) 
142
+
234 143
 if stance == 1 and skater.isPlayingAction(fliplay) == False and yBut == False and r_ground.triggered and xBut == False and noidle == 0 and own['walk_idling'] == 0 and own['sit'] == 0 and own['dropinTimer'] == 0 and own['lasty']  == False:
235 144
     own['requestAction'] = 'fak_idle'
236 145
     if own['throw_deck'] == True:
237 146
         own['requestAction'] = 'fak_idle_nb'
238
-        #skater.playAction("fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
239
-    #else:
240
-        #skater.playAction("fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
241
-        #deck.playAction("a_fak_idle1", 1,120, layer=3, play_mode=1, speed=.5)
242
-        #trucks.playAction("a_fak_idle1", 1,120, layer=3, play_mode=1, speed=.5) 
243 147
 
244 148
 if lUD < -sens:
245 149
     lup = 1
@@ -253,7 +157,6 @@ else:
253 157
 #walking
254 158
 
255 159
 #new walking
256
-#if (lup == 1 and aBut == 0 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0):
257 160
 vel = own.getLinearVelocity(True)
258 161
 if own['walk_timer'] < 50:
259 162
     velx = vel.x * .95             
@@ -310,131 +213,55 @@ if (lup == 1 and aBut == 0 and yBut == False and (r_ground.positive or own['stai
310 213
     own.actuators["walkondirt"].volume = .2
311 214
     own.actuators["walkondirt"].pitch = 1
312 215
     cont.activate(own.actuators["walkondirt"])
313
-    if lasta == 1:
314
-        #cont.deactivate(own.actuators['forward2']) 
315
-        #cont.deactivate(own.actuators['backward2'])
316
-        killact(6)
317
-        killact(7)
318
-        killact(8)
319
-        killact(9)
320
-        killact(17)
321
-        killact(18)                
216
+                
322 217
     if stance == 0 and skater.isPlayingAction(fliplay) == False:             
323
-        #cont.activate(own.actuators['forward'])
324
-        #cont.activate(skater.actuators['aWalk'])
325
-        #cont.activate(deck.actuators['a_reg_walk'])
326
-        #cont.activate(deck.actuators['a_reg_walk'])
327 218
         #without deck
328 219
         if own['throw_deck'] == True:
329 220
             own['requestAction'] = 'reg_walk_nb'
330
-            #skater.playAction("reg_nwalk_nb.001", 0,35, layer=24, play_mode=1, speed=.5)
331 221
         else:
332 222
             own['requestAction'] = 'reg_walk'
333
-#            skater.playAction("reg_nwalk", 0,35, layer=24, play_mode=1, speed=.5)
334
-#        deck.playAction("a_reg_nwalk", 0,35, layer=16, play_mode=1, speed=.5)
335
-#        trucks.playAction("a_reg_nwalk", 0,35, layer=16, play_mode=1, speed=.5)
336
-        killact(25) 
337
-        killact(305)
338
-        killact(306)                
223
+               
339 224
     if stance == 1 and skater.isPlayingAction(fliplay) == False:        
340
-        #cont.activate(own.actuators['backward'])
341
-        #cont.activate(skater.actuators['aWalk_fak'])
342
-        #cont.activate(deck.actuators['a_fak_walk'])
343
-        #cont.activate(trucks.actuators['a_fak_walk'])
344 225
         #without deck
345 226
         if own['throw_deck'] == True:
346 227
             own['requestAction'] = 'fak_walk_nb'
347
-            #skater.playAction("fak_nwalk_nb.001", 0,35, layer=25, play_mode=1, speed=.5)
348 228
         else:
349 229
             own['requestAction'] = 'fak_walk'
350
-#            skater.playAction("fak_nwalk", 0,35, layer=25, play_mode=1, speed=.5)    
351
-#        deck.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=.5)
352
-#        trucks.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=.5)        
230
+       
353 231
 elif lup == 1 and aBut == 1 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
354 232
     own.actuators["walkondirt"].volume = .2
355 233
     own.actuators["walkondirt"].pitch = 1.3
356 234
     cont.activate(own.actuators["walkondirt"])
357 235
     if stance == 0 and skater.isPlayingAction(fliplay) == False:        
358
-        #cont.activate(own.actuators['forward2'])
359
-        #cont.activate(skater.actuators['aWalk'])
360 236
         if own['throw_deck'] == True:
361 237
             own['requestAction'] = 'reg_walkFast_nb'
362 238
             skater.playAction("reg_nwalk_nb.001", 0,35, layer=25, play_mode=1, speed=1)
363 239
         else:
364 240
             own['requestAction'] = 'reg_walkFast'
365
-#            skater.playAction("reg_nwalk", 0,35, layer=25, play_mode=1, speed=1)         
366
-#        
367
-#        deck.playAction("a_reg_nwalk", 0,35, layer=305, play_mode=1, speed=1)
368
-#        trucks.playAction("a_reg_nwalk", 0,35, layer=306, play_mode=1, speed=1)
241
+
369 242
     else:
370 243
         killact(25) 
371 244
         killact(305)
372 245
         killact(306)           
373 246
     if stance == 1 and skater.isPlayingAction(fliplay) == False:        
374
-        #cont.activate(own.actuators['backward2'])
375
-        #cont.activate(skater.actuators['aWalk_fak'])
376 247
         if own['throw_deck'] == True:
377 248
             own['requestAction'] = 'fak_walkFast_nb'
378 249
             skater.playAction("fak_nwalk_nb.001", 0,35, layer=24, play_mode=1, speed=1)           
379 250
         else:
380
-            own['requestAction'] = 'fak_walkFast'
381
-#            skater.playAction("fak_nwalk", 0,35, layer=24, play_mode=1, speed=1)                       
382
-#        deck.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=1)
383
-#        trucks.playAction("a_fak_nwalk", 0,35, layer=15, play_mode=1, speed=1)             
251
+            own['requestAction'] = 'fak_walkFast'             
384 252
 else:
385 253
     vel = own.getLinearVelocity(True)
386 254
     cont.deactivate(own.actuators["walkondirt"])
387 255
     if stance == 0:
388
-        #cont.deactivate(own.actuators['forward'])
389
-        #cont.deactivate(own.actuators['forward2'])
390 256
         cont.deactivate(skater.actuators['aWalk'])
391 257
         cont.deactivate(deck.actuators['a_reg_walk'])
392 258
         cont.deactivate(trucks.actuators['a_reg_walk'])        
393
-        killact(4)
394
-        killact(5)
395
-        killact(6)
396
-        killact(7)
397
-        killact(15)
398
-        killact(16)
399
-        killact(17)
400
-        killact(18)
401
-        killact(24)
402
-        killact(25) 
403
-        killact(305)
404
-        killact(306)         
405
-#        if own['walk_timer'] < 50:
406
-#            velx = vel.x * .95             
407
-#            #own.setLinearVelocity([velx, 0, vel.z], True)
408
-#            
409
-#        else:
410
-#            if r_ground.triggered:
411
-#                own.setLinearVelocity([0, 0, vel.z], True)
412
-#            #velz = vel.z
413
-#            #print(velz)
414
-#            #own.localLinearVelocity[0, 0, velz]
259
+
415 260
     if stance == 1:
416
-        #cont.deactivate(own.actuators['backward'])
417
-        #cont.deactivate(own.actuators['backward2'])
418 261
         cont.deactivate(skater.actuators['aWalk_fak'])
419 262
         cont.deactivate(deck.actuators['a_fak_walk'])
420 263
         cont.deactivate(trucks.actuators['a_fak_walk'])        
421
-        killact(4)
422
-        killact(5)
423
-        killact(6)
424
-        killact(7)
425
-        killact(15)
426
-        killact(16)
427
-        killact(17)
428
-        killact(18)
429
-        killact(24)
430
-        killact(25) 
431
-        killact(305)
432
-        killact(306)             
433
-#        if own['walk_timer'] < 50:
434
-#            velx = vel.x * .95             
435
-#            #own.setLinearVelocity([velx, 0, vel.z], True)
436
-#        else:
437
-#            own.setLinearVelocity([0, 0, vel.z], True)
264
+
438 265
 #in air        
439 266
 if lup == 1 and r_ground.positive == False:
440 267
     
@@ -448,7 +275,6 @@ if lup == 1 and r_ground.positive == False:
448 275
         killact(7)        
449 276
         velx = linvel.x - 1
450 277
         own.setLinearVelocity([-1.5, linvel.y, linvel.z], 1)
451
-        #cont.activate(own.actuators['forward2'])
452 278
     if stance == 1:    
453 279
         cont.deactivate(own.actuators['backward'])
454 280
         cont.deactivate(own.actuators['backward2'])
@@ -458,8 +284,7 @@ if lup == 1 and r_ground.positive == False:
458 284
         killact(6)
459 285
         killact(7)        
460 286
         velx = linvel.x + 1
461
-        own.setLinearVelocity([1.5, linvel.y, linvel.z], 1) 
462
-        #cont.activate(own.actuators['backward2'])       
287
+        own.setLinearVelocity([1.5, linvel.y, linvel.z], 1)       
463 288
 #---------------
464 289
 if rLR > .05:
465 290
     cont.activate(camobj.actuators['camRight'])
@@ -510,18 +335,7 @@ def onboard():
510 335
         fliplay3 = 303
511 336
         try:
512 337
             vel = own['offboard_vel']
513
-            #velx = vel.x *2
514
-            vel = [velx, vel.y, vel.z]
515
-            #vel = vel * 4
516
-            #vel = [-100, 0, 0]
517
-            #print(vel)
518
-            #own.localLinearVelocity = vel
519
-            #JUMPHEIGHT = 1100
520
-            #force = [600, 0.0, 10]
521
-            # use local axis
522
-            #local = True
523
-            # apply force
524
-            #own.applyForce(force, local)            
338
+            vel = [velx, vel.y, vel.z]           
525 339
         except: 
526 340
             pass
527 341
          
@@ -533,10 +347,7 @@ def onboard():
533 347
             deck.stopAction(deckon)
534 348
             trucks.stopAction(truckon)
535 349
             own['requestAction'] = 'reg_offboard'             
536
-
537
-#            skater.playAction("reg_noffboard", 0,26, layer=fliplay, priority=0, play_mode=0, speed=.5)
538
-#            deck.playAction("a_reg_noffboard", 0,26, layer=deckon, priority=0, play_mode=0, speed=.5)
539
-#            trucks.playAction("a_reg_noffboard", 0,26, layer=truckon, priority=0, play_mode=0, speed=.5)            
350
+            
540 351
         if STANCE == 1:
541 352
             killact(3)
542 353
             killact(4)
@@ -544,10 +355,7 @@ def onboard():
544 355
             skater.stopAction(fliplay)
545 356
             deck.stopAction(deckon)
546 357
             trucks.stopAction(truckon)
547
-            own['requestAction'] = 'fak_offboard'             
548
-#            skater.playAction("nfak_offboard", 1,30, layer=fliplay, priority=0, play_mode=0, speed=1.5)
549
-#            deck.playAction("a_fak_offboard", 1,30, layer=deckon, priority=0, play_mode=0, speed=1.5)
550
-#            trucks.playAction("a_fak_offboard", 1,30, layer=truckon, priority=0, play_mode=0, speed=1.5)             
358
+            own['requestAction'] = 'fak_offboard'                          
551 359
 def jump():
552 360
     if xBut == True:
553 361
         if own['lastx'] == 0:
@@ -555,18 +363,11 @@ def jump():
555 363
             killact(4)
556 364
             killact(5)
557 365
             killact(6)
558
-            killact(7) 
559
-            #why does this layer have to be so high?      
366
+            killact(7)      
560 367
             if STANCE == 0:  
561 368
                 own['requestAction'] ='reg_jump'   
562
-#                skater.playAction("reg_jump", 1,35, layer=400, priority=0, play_mode=0, speed=.5)
563
-#                deck.playAction("a_reg_jump2", 1,35, layer=400, priority=0, play_mode=0, speed=.5)
564
-#                trucks.playAction("a_reg_jump2", 1,35, layer=400, priority=0, play_mode=0, speed=.5)
565 369
             if STANCE == 1:
566
-                own['requestAction'] ='fak_jump'
567
-                #skater.playAction("fak_jump", 1,35, layer=400, priority=0, play_mode=0, speed=.5)    
568
-            #deck.playAction("a_reg_jump", 1,30, layer=11, play_mode=0, speed=.5)
569
-            #trucks.playAction("a_reg_jump", 1,30, layer=12, priority=0, play_mode=0, speed=1)             
370
+                own['requestAction'] ='fak_jump'             
570 371
             JUMPHEIGHT = 1100
571 372
             force = [ 0.0, 0.0, JUMPHEIGHT]
572 373
             # use local axis
@@ -578,7 +379,6 @@ def jump():
578 379
         own['lastx'] = 0
579 380
 def dropin():
580 381
     if dropinCol.positive == True:
581
-        #print("DROPIN") 
582 382
         pass       
583 383
         
584 384
 def getonboard():
@@ -982,9 +782,7 @@ def sit():
982 782
         own['sit'] = 0
983 783
 
984 784
     if aBut == False and lasta == True:
985
-        #print(lasta)
986 785
         try:
987
-            #print(r_ground.hitObject)
988 786
             if 'sit' in r_ground.hitObject:
989 787
                 print("sit")
990 788
                 own['sit'] = 1
@@ -998,12 +796,7 @@ def sit():
998 796
                     skater.playAction("fak_sit", 1,65, layer=300, play_mode=0, speed=1)
999 797
                     deck.playAction("a_fak_sit", 1,65, layer=300, play_mode=0, speed=1)
1000 798
                     trucks.playAction("a_fak_sit", 1,65, layer=300, play_mode=0, speed=1)                                         
1001
-    #if own['sit'] == 1 and last_sit == 0:
1002
-                 
1003
-                     
1004
-                
1005 799
         except:
1006
-            #print("sit broke")
1007 800
             pass    
1008 801
     if own['sit'] == 1:
1009 802
         try:
@@ -1271,8 +1064,8 @@ if r_ground.triggered == False:
1271 1064
 else:
1272 1065
     cont.activate(own.actuators["walk_align"])                    
1273 1066
 
1067
+#walking on stairs
1274 1068
 if r_ground.triggered:
1275
-    #print("on stair")
1276 1069
     try:
1277 1070
         if 'stair' in r_ground.hitObject:
1278 1071
             own['stair_counter'] = 20

Loading…
Cancel
Save