shuvit 6 years ago
parent
commit
545ed9ff6f
6 changed files with 86 additions and 105 deletions
  1. 9
    3
      co_ActionState.py
  2. 2
    1
      controller2.py
  3. 48
    91
      grindV2.py
  4. 1
    0
      scene_init.py
  5. 20
    8
      stance.py
  6. 6
    2
      walk.py

+ 9
- 3
co_ActionState.py View File

@@ -85,6 +85,12 @@ def main():
85 85
     if requestAction in ['reg_offboard', 'fak_offboard', 'reg_onboard', 'fak_onboard']:
86 86
         own['actionTimer'] = 0
87 87
         actionTimer = 0
88
+    if l_actionState == 'reg_dropin_pos' and requestAction != 'reg_dropin_pos':
89
+        own['requestAction'] = 'reg_dropin'
90
+        requestAction = 'reg_dropin'
91
+    if l_actionState == 'fak_dropin_pos' and requestAction != 'fak_dropin_pos':
92
+        own['requestAction'] = 'fak_dropin'
93
+        requestAction = 'fak_dropin'        
88 94
 
89 95
 #===============        
90 96
     #land action over ride
@@ -311,14 +317,14 @@ def main():
311 317
         if (l_actionState == 'reg_5050_out' and requestAction == 'reg_roll') or (l_actionState in {'reg_noseg_out', 'reg_nosegr_out', 'reg_nosegl_out', 'reg_tailg_out', 'reg_tailgr_out', 'reg_tailgl_out'} and actionTimer < 10):    
312 318
             requestAction = 'reg_5050-roll'
313 319
             actionState = 'reg_5050-roll'
314
-            print('************************')  
320
+            #print('************************')  
315 321
         
316 322
         if (l_actionState == 'fak_5050_out' and requestAction == 'fak_roll') or (l_actionState in {'fak_noseg_out', 'fak_nosegr_out', 'fak_nosegl_out', 'fak_tailg_out', 'fak_tailgr_out', 'fak_tailgl_out'} and actionTimer < 10): 
317 323
             requestAction = 'fak_5050-roll'
318 324
             actionState = 'fak_5050-roll' 
319
-            print('************************')                                                                                                                  
325
+            #print('************************')                                                                                                                  
320 326
     else:
321
-        print("action over ridden")               
327
+        print("action over written")               
322 328
     def updateAction(requestAction, actionState):
323 329
         try:
324 330
             flip_start_frame = own['flip_start_lay']

+ 2
- 1
controller2.py View File

@@ -1568,6 +1568,7 @@ def main():
1568 1568
         if framenumber == 900000:
1569 1569
             framenumber = 0
1570 1570
         own["framenum"] = framenumber
1571
+        own['last_roll_frame'] = framenumber
1571 1572
         
1572 1573
     def push():
1573 1574
         local = True
@@ -2177,7 +2178,7 @@ def main():
2177 2178
             own["coping"] = 0    
2178 2179
     #print(own['dropinTimer'], 'dtimer')
2179 2180
     def onboard():
2180
-        if own['walk'] == 1 and own['lasty'] == False:
2181
+        if own['walk'] == 1 and own['lasty'] == False and own['requestAction'] not in ['reg_dropin', 'fak_dropin']:
2181 2182
             cont.deactivate(cam.actuators['replayCam'])
2182 2183
             cont.activate(cam.actuators['Camera'])
2183 2184
             killall()

+ 48
- 91
grindV2.py View File

@@ -139,8 +139,8 @@ def main():
139 139
         if rot >= 270 and rot < 315: 
140 140
             grindvect = "pos" 
141 141
             grindyvect = "neg"
142
-        if rot >= 315: grindvect = "pos"
143
-        
142
+        if rot >= 315: 
143
+            grindvect = "pos"
144 144
         if rot < 0 and rot >= -45: 
145 145
             grindvect = "pos"
146 146
         if rot < -45 and rot >= -90: 
@@ -218,7 +218,8 @@ def main():
218 218
 
219 219
         #z align
220 220
         #print("zalign") 
221
-        player.alignAxisToVect(grinder_vectz, 2, .15)                                                  
221
+        stre = .15
222
+        player.alignAxisToVect(grinder_vectz, 2, stre)                                                  
222 223
         
223 224
         if rot >= 0 and rot < 45:
224 225
             player.alignAxisToVect(grinder_vect, 0, align_strength)
@@ -226,173 +227,126 @@ def main():
226 227
             #player.applyForce([0, 0, 0], True)            
227 228
             player.setLinearVelocity([velxb, 0.0, zvel], 1)  
228 229
             grindpos = "reg_5050"
230
+            print("50-1")
229 231
 
230 232
 
231
-        if rot >= 45 and rot < 90:  
232
-            #90 degrees CW about z-axis: (x, y, z) -> (y, -x, z)
233
-            #90 degrees CCW about z-axis: (x, y, z) -> (-y, x, z) 
234
-            #grinder_vect2 =                 
235
-            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, grinder_vect.z], 0, align_strength)
236
-            #print("1") 
233
+        elif rot >= 45 and rot < 90:  
234
+            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, 0], 0, align_strength)
237 235
             grindvect = "pos"
238
-            #player.applyRotation(bsrot, 1)
239
-            align = "pos"
240
-            #player.applyForce([0, 0, 0], True)
236
+            align = "pos"            
241 237
             player.setLinearVelocity([0, convely, zvel], 1)   
242 238
             grindpos = "reg_board"     
243 239
             grindyvect = "pos"
244 240
             #print("bs1, don't switch")       
245
-            #print("boardslide")
246 241
                            
247
-        if rot >= 90 and rot < 135:  
248
-            #print(STANCE, "2") 
242
+        elif rot >= 90 and rot < 135:  
249 243
             grinder_vect = grinder_vect * -1                
250
-            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength) 
244
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength) 
251 245
             grindvect = "neg"
252
-            #print("2")
253
-            #player.applyRotation(negbsrot, 1)
254 246
             align = "neg"
255 247
             grindyvect = "neg"
256
-            #player.applyForce([0, 0, 0], True)
257 248
             player.setLinearVelocity([0, convely, zvel], 1)
258 249
             grindpos = "reg_board"  
259 250
             #print("-bs2, don't switch?")          
260
-            #print("boardslide") 
261 251
                      
262
-        if rot >= 135 and rot < 180:
252
+        elif rot >= 135 and rot < 180:
263 253
             player.alignAxisToVect(-grinder_vect, 0, align_strength)
264 254
             grindvect = "neg"
265
-            #player.applyForce([0, 0, 0], True)
266 255
             player.setLinearVelocity([velxb, 0.0, zvel], 1) 
267 256
             grindpos = "reg_5050"
257
+            #print("50-2")
268 258
            
269
-        if rot >= 180 and rot < 225:
259
+        elif rot >= 180 and rot < 225:
270 260
             player.alignAxisToVect(-grinder_vect, 0, align_strength)
271 261
             grindvect = "neg"
272
-            #player.applyForce([0, 0, 0], True)
273 262
             player.setLinearVelocity([velxb, 0.0, zvel], 1)
274 263
             grindpos = "reg_5050" 
264
+            #print("50-3")
275 265
             
276
-        if rot >= 225 and rot < 270:
277
-            #print(STANCE, "3")
278
-            #grinder_vect = grinder_vect * -1
279
-            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength)
280
-            #print("3")
266
+        elif rot >= 225 and rot < 270:
267
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength)
281 268
             grindvect = "neg"
282
-            #player.applyRotation(bsrot, 1)
283 269
             align = "pos"
284
-            #player.applyForce([0, 0, 0], True)
285 270
             player.setLinearVelocity([0, convely, zvel], 1)
286 271
             grindpos = "reg_board"
287 272
             grindyvect = "pos"
288
-            print("bs3")             
289
-            #print("boardslide")
273
+            #print("bs3")             
290 274
            
291
-        if rot >= 270 and rot < 315:
292
-            #print(STANCE, "4")
293
-            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength) 
294
-            grindvect = "pos"
295
-            #player.applyRotation(negbsrot, 1)
296
-            #print("4")  
275
+        elif rot >= 270 and rot < 315:
276
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength) 
277
+            grindvect = "pos" 
297 278
             align = "neg"
298
-            #player.applyForce([0, 0, 0], True)
299 279
             player.setLinearVelocity([0, convely, zvel], 1)
300 280
             grindpos = "reg_board"   
301 281
             grindyvect = "neg"
302
-            #print("-bs4")              
303
-            #print("boardslide")
282
+            #print("-bs4")          
304 283
             
305
-        if rot >= 315:
284
+        elif rot >= 315:
306 285
             player.alignAxisToVect(grinder_vect, 0, align_strength)
307 286
             grindvect = "pos"
308
-            #player.applyForce([0, 0, 0], True)
309 287
             player.setLinearVelocity([velxb, 0.0, zvel], 1)
310 288
             grindpos = "reg_5050"
289
+            #print("50-4")
311 290
                          
312 291
 #-------------------------------------------------------------            
313
-        if rot < 0 and rot >= -45:
292
+        elif rot < 0 and rot >= -45:
314 293
             player.alignAxisToVect(grinder_vect, 0, align_strength)
315 294
             grindvect = "pos"
316
-            #player.applyForce([0, 0, 0], True)
317 295
             player.setLinearVelocity([velxb, 0.0, zvel], 1)  
318
-            grindpos = "reg_5050"   
319
-                                  
320
-        if rot < -45 and rot >= -90:
321
-            #print(STANCE, "5")
296
+            grindpos = "reg_5050" 
297
+            #print("50-5")                    
298
+        elif rot < -45 and rot >= -90:
322 299
             grinder_vect = grinder_vect * -1
323
-            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, grinder_vect.z], 0, align_strength)
300
+            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, 0], 0, align_strength)
324 301
             grindvect = "pos"
325
-            #player.applyRotation(negbsrot, 1)
326
-            #print("5")
327 302
             align = "neg"
328
-            #player.applyForce([0, 0, 0], True)
329 303
             player.setLinearVelocity([0, convely, zvel], 1)
330 304
             grindpos = "reg_board"   
331 305
             #print("-bs5")           
332
-            #print("boardslide")
333
-            
334 306
             grindyvect = "neg"
335
-        if rot < -90 and rot >= -135:
336
-            #print(STANCE, "6")
337
-            #grinder_vect = grinder_vect * -1
338
-            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength) 
307
+        elif rot < -90 and rot >= -135:
308
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength)
339 309
             grindvect = "neg"
340
-            #print("6")
341
-            #player.applyRotation(bsrot, 1)
342 310
             align = "pos"
343
-            #player.applyForce([0, 0, 0], True)
344 311
             player.setLinearVelocity([0, convely, zvel], 1)
345 312
             grindpos = "reg_board"  
346 313
             grindyvect = "pos"
347
-            #print("bs6")           
348
-            #print("boardslide") 
349
-                                           
350
-        if rot < -135 and rot >= -180:
314
+            #print("bs6")                   
315
+        elif rot < -135 and rot >= -180:
351 316
             player.alignAxisToVect(-grinder_vect, 0, align_strength)
352 317
             grindvect = "neg"   
353
-            #player.applyForce([0, 0, 0], True)
354 318
             player.setLinearVelocity([velxb, 0.0, zvel], 1)  
355 319
             grindpos = "reg_5050" 
356
-                       
357
-        if rot < -180 and rot >= -225:
320
+            #print("50-6")       
321
+        elif rot < -180 and rot >= -225:
358 322
             player.alignAxisToVect(-grinder_vect, 0, align_strength) 
359 323
             grindvect = "neg"           
360
-            #player.applyForce([0, 0, 0], True)
361 324
             player.setLinearVelocity([velxb, 0.0, zvel], 1)  
362 325
             grindpos = "reg_5050" 
363
-        if rot < -225 and rot >= -270:
364
-            #print(STANCE, "7")
326
+            #print("50-7")
327
+        elif rot < -225 and rot >= -270:
365 328
             grinder_vect = grinder_vect * -1
366
-            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, grinder_vect.z], 0, align_strength) 
329
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength) 
367 330
             grindvect = "neg"
368
-            #player.applyRotation(negbsrot, 1)
369
-            #print("7")
370 331
             align = "neg"
371
-            #player.applyForce([0, 0, 0], True)
372 332
             player.setLinearVelocity([0, convely, zvel], 1)
373 333
             grindpos = "reg_board"   
374 334
             grindyvect = "neg"
375
-            #print("-bs7")          
376
-            #print("boardslide")            
377
-        if rot < -270 and rot >= -315:
378
-            #print(STANCE, "8")
379
-            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, grinder_vect.z], 0, align_strength) 
335
+            #print("-bs7")              
336
+        elif rot < -270 and rot >= -315:
337
+            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, 0], 0, align_strength) 
380 338
             grindvect = "pos"
381
-            #player.applyRotation(bsrot, 1)
382
-            #print("8")
383 339
             align = "pos"
384
-            #player.applyForce([0, 0, 0], True)
385 340
             player.setLinearVelocity([0, convely, zvel], 1)
386 341
             grindpos = "reg_board"    
387 342
             grindyvect = "pos"
388
-            #print("bs8")        
389
-            #print("boardslide")                                
390
-        if rot < -315:
343
+            #print("bs8")                                   
344
+        elif rot < -315:
391 345
             player.alignAxisToVect(grinder_vect, 0, align_strength) 
392 346
             grindvect = "pos"                     
393
-            #player.applyForce([0, 0, 0], True)
394 347
             player.setLinearVelocity([velxb, 0.0, zvel], 1)  
395 348
             grindpos = "reg_5050"  
349
+            #print("50-8")
396 350
 
397 351
         own['grindpos'] = grindpos
398 352
         own['grindvect'] = grindvect
@@ -451,7 +405,8 @@ def main():
451 405
                     player_rotz = math.degrees(player_e[2])
452 406
                     grinder_e = obj.worldOrientation.to_euler()
453 407
                     grinder_rotz = math.degrees(grinder_e[2])
454
-                    deltamove = delta[2] * .3#.25
408
+                    deltamove = delta[2] * .3
409
+                    #print(round(deltamove, 4), "deltamove")
455 410
                     #5050
456 411
                     if own["grindpos"] == "reg_5050":
457 412
                         #print("missing delta")
@@ -558,9 +513,11 @@ def main():
558 513
                 if grindTouch.positive:
559 514
                     nearpos = nearestObject.worldPosition
560 515
                     if hitNormal != None:
561
-                        own.alignAxisToVect(hitNormal, 2, .05) 
516
+                        stre = .05
517
+                        own.alignAxisToVect(hitNormal, 2, stre) 
562 518
                         print("align")                   
563 519
                     own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
520
+                    print('moving world')
564 521
 
565 522
             grindold = True
566 523
             own['grindold_timer'] = 0

+ 1
- 0
scene_init.py View File

@@ -23,6 +23,7 @@ def main():
23 23
     dict['overlay_fadeout'] = 1
24 24
     scenes = bge.logic.getSceneList()
25 25
     own['pre_pause_linvel'] = 0.0
26
+    #own['last_roll_frame'] = 0
26 27
     for i in scenes:
27 28
         if i.name == "main":
28 29
             main = i

+ 20
- 8
stance.py View File

@@ -3,6 +3,18 @@ from bge import logic
3 3
 cont = bge.logic.getCurrentController()
4 4
 own = cont.owner
5 5
 
6
+
7
+#scene = bge.logic.getCurrentScene()
8
+#control_bottom = scene.objects['control_bottom']
9
+#grindTouch = control_bottom.sensors['grindCol_bottom']
10
+#edge = 0
11
+#try:
12
+#    if 'edge' in grindTouch.hitObject:
13
+#        print('Edge')
14
+#        edge = 1
15
+#except:
16
+#    pass        
17
+
6 18
 #constants
7 19
 STANCE_SENS = 0.05
8 20
 STANCE = own["stance"]
@@ -22,14 +34,14 @@ try:
22 34
             STANCE = 0
23 35
 except:
24 36
     print("no stance")
25
-if jumpstance == 3:
26
-    if own["grindOld"] == 0:
27
-        own["stance"] = STANCE
28
-else:
29
-    if grindpos == "reg_5050":
30
-        own["stance"] = STANCE
31
-    else:
32
-        STANCE = jumpstance
37
+#if jumpstance == 3:
38
+#    if own["grindOld"] == 0:
39
+#        own["stance"] = STANCE
40
+#else:
41
+#    if grindpos == "reg_5050":
42
+#        own["stance"] = STANCE
43
+#    else:
44
+#        STANCE = jumpstance
33 45
 own["stance"] = STANCE           
34 46
 dict = bge.logic.globalDict #Get the global dictionary
35 47
 dict['stance'] = STANCE #Store the new score

+ 6
- 2
walk.py View File

@@ -262,10 +262,14 @@ else:
262 262
     own.setLinearVelocity([0, 0, vel.z], True)
263 263
     #print("set 0 vel")
264 264
     
265
-if (lup == 1 and aBut == 0 and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0):    
265
+wf = 1
266
+if own['last_walk_frame'] - own['last_roll_frame'] > 55:
267
+    wf = 0
268
+   
269
+if (lup == 1 and aBut == 0 and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0) and wf == 0:    
266 270
     own['walking'] = "regular"
267 271
     walking = "regular"
268
-elif lup == 1 and aBut == 1 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0:
272
+elif lup == 1 and aBut == 1 and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0 and wf == 0:
269 273
     own['walking'] = "fast"
270 274
     walking = "fast"
271 275
 else:

Loading…
Cancel
Save