shuvit 5 years ago
parent
commit
793dbc3c5e
8 changed files with 284 additions and 291 deletions
  1. 5
    0
      Startup.py
  2. 44
    60
      car.py
  3. 127
    180
      co_ActionState.py
  4. 6
    24
      controller2.py
  5. 38
    0
      load_char.py
  6. 1
    1
      menuV3.py
  7. 1
    0
      scene_init.py
  8. 62
    26
      walk.py

+ 5
- 0
Startup.py View File

@@ -133,5 +133,10 @@ def main():
133 133
     
134 134
     dict['joy_con'] = 1
135 135
     dict['last_joy_con'] = 1
136
+    dict['last_driving'] = False
137
+    
138
+    dict['spawned_npc_decks'] = []
139
+    dict['spawned_npc_trucks'] = []    
140
+    dict['spawned_npcs'] = []
136 141
 
137 142
 main()

+ 44
- 60
car.py View File

@@ -22,7 +22,7 @@ import bge
22 22
 import GameLogic
23 23
 import ctypes
24 24
 
25
-
25
+dict = bge.logic.globalDict 
26 26
 
27 27
 
28 28
 reduction = 400000
@@ -31,43 +31,6 @@ axisTh = 0.03
31 31
 cont = GameLogic.getCurrentController() 
32 32
 obj = bge.logic.getCurrentScene().objects
33 33
 own = cont.owner
34
-#Sensor logic bricks connected to the python Controller  
35
-aXis = cont.sensors["sCont"]
36
-bUtt = cont.sensors["sContb"]
37
-
38
-
39
-onW = onWindows()
40
-
41
-# windows stuff
42
-lar_lts = 0
43
-uad_lts = 1
44
-lt = 4 if onW else 2
45
-lar_rts = 2 if onW else 3
46
-uad_rts = 3 if onW else 4
47
-rt = 5
48
-
49
-a_but = 0 if onW else 0
50
-b_but = 1 if onW else 1
51
-x_but = 2 if onW else 2
52
-y_but = 3 if onW else 3
53
-l_bump = 9 if onW else 4
54
-r_bump = 10 if onW else 5
55
-bk_but = 4 if onW else 6
56
-st_but = 6 if onW else 7
57
-xb_but = 5 if onW else 8
58
-lts_pr = 7 if onW else 9
59
-rts_pr = 8 if onW else 10
60
-l_dp = 13 if onW else 11
61
-r_dp = 14 if onW else 12
62
-u_dp = 11 if onW else 13
63
-d_dp = 12 if onW else 14
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71 34
 
72 35
 class CarSetup:
73 36
     
@@ -793,30 +756,49 @@ def _steer(controller, car):
793 756
         vehicleID.setSteeringValue(carsetup.turnAmount[car],0)
794 757
         vehicleID.setSteeringValue(carsetup.turnAmount[car],1)
795 758
 
759
+def exit():
760
+    print('exit car')
761
+    scene = bge.logic.getCurrentScene()
762
+    cube = scene.objects['control_cube.002']
763
+    own['driving'] = False
764
+    cube['driving'] = False
765
+
766
+    cube.applyMovement([0,-1,0], True)
767
+    cube.removeParent()
768
+    cube.suspendDynamics(False)
769
+    #cont.actuators['Camera'].object = obj
770
+    
771
+    
772
+    
773
+def check_exit(yBut):
774
+    if yBut == True and dict['last_yBut'] == False:
775
+        exit()
776
+    else:
777
+        dict['last_driving'] = True    
796 778
     
797 779
 def main(controller):
798 780
 
799
-    lLR = aXis.axisValues[lar_lts] / reduction
800
-    lUD = aXis.axisValues[uad_lts] / reduction
801
-    rLR = aXis.axisValues[lar_rts] / reduction
802
-    rUD = aXis.axisValues[uad_rts] / reduction
803
-    lTrig = aXis.axisValues[lt] / reduction
804
-    rTrig = aXis.axisValues[rt] / reduction
805
-    aBut = bUtt.getButtonStatus(a_but)
806
-    bBut = bUtt.getButtonStatus(b_but)
807
-    xBut = bUtt.getButtonStatus(x_but)
808
-    yBut = bUtt.getButtonStatus(y_but)
809
-    lBump = bUtt.getButtonStatus(l_bump)
810
-    rBump = bUtt.getButtonStatus(r_bump)
811
-    bkBut = bUtt.getButtonStatus(bk_but)
812
-    stBut = bUtt.getButtonStatus(st_but)
813
-    xbBut = bUtt.getButtonStatus(xb_but)
814
-    ltsBut = bUtt.getButtonStatus(lts_pr)
815
-    rtsBut = bUtt.getButtonStatus(rts_pr)
816
-    ldPad = bUtt.getButtonStatus(l_dp)
817
-    rdPad = bUtt.getButtonStatus(r_dp)
818
-    udPad = bUtt.getButtonStatus(u_dp)
819
-    ddPad = bUtt.getButtonStatus(d_dp)
781
+    lLR = dict['lLR']
782
+    lUD = dict['lUD']
783
+    rLR = dict['rLR']
784
+    rUD = dict['rUD']
785
+    lTrig = dict['lTrig']
786
+    rTrig = dict['rTrig']
787
+    aBut = dict['aBut']
788
+    bBut = dict['bBut']
789
+    xBut = dict['xBut']
790
+    yBut = dict['yBut']
791
+    lBump = dict['lBump']
792
+    rBump = dict['rBump']
793
+    bkBut = dict['bkBut']
794
+    stBut = dict['stBut']
795
+    xbBut = dict['xbBut']
796
+    ltsBut = dict['ltsBut']
797
+    rtsBut = dict['rtsBut']
798
+    ldPad = dict['ldPad']
799
+    rdPad = dict['rdPad']
800
+    udPad = dict['udPad']
801
+    ddPad = dict['ddPad']
820 802
 
821 803
     #no input
822 804
     def cutOff():    
@@ -887,4 +869,6 @@ def main(controller):
887 869
     _powertrain(controller, car)
888 870
     
889 871
     #run powertrain
890
-    _steer(controller, car)
872
+    _steer(controller, car)
873
+    
874
+    check_exit(yBut)

+ 127
- 180
co_ActionState.py
File diff suppressed because it is too large
View File


+ 6
- 24
controller2.py View File

@@ -187,7 +187,7 @@ def main():
187 187
 
188 188
     #setable
189 189
     grablay = 600 #this plus 1
190
-    fliplay = 470
190
+    fliplay = 4
191 191
     MAX_VEL = 6.7
192 192
     SPEEDUP = .055
193 193
     SPEEDPUMP = .14 #.09
@@ -2242,14 +2242,7 @@ def main():
2242 2242
                 STANCE = 0 
2243 2243
                 own['lg_stance'] = 0
2244 2244
                 lg_stance = 0
2245
-                #print('changing stance 0') 
2246
-                
2247
-#            if 'reg' in own['l_actionState'] and STANCE == 1:
2248
-#                print('wrong grind stance', own['requestAction'])    
2249
-#            else:
2250
-#                print('ok')    
2251
-                
2252
-                
2245
+                #print('changing stance 0')                 
2253 2246
             own['stance'] = STANCE                         
2254 2247
                       
2255 2248
     def rotmult():
@@ -2328,13 +2321,9 @@ def main():
2328 2321
             cont.deactivate(cam.actuators['replayCam'])
2329 2322
             cont.activate(cam.actuators['Camera'])
2330 2323
             killall()
2331
-            walklay = 40
2332
-            fliplay3 = 2060  
2324
+            walklay = 40 
2333 2325
             ob_speed = .5
2334 2326
             if STANCE == 0:
2335
-                skater.stopAction(fliplay)
2336
-                deck.stopAction(fliplay)
2337
-                trucks.stopAction(fliplay)
2338 2327
                 killall() 
2339 2328
                 if own['dropinCol'] == True:
2340 2329
                     own['requestAction'] = 'reg_dropin'
@@ -2345,9 +2334,6 @@ def main():
2345 2334
                     if own['dropinTimer'] == 0:
2346 2335
                         own.setLinearVelocity(force, True)
2347 2336
             if STANCE == 1:
2348
-                skater.stopAction(fliplay)
2349
-                deck.stopAction(fliplay)
2350
-                trucks.stopAction(fliplay)
2351 2337
                 killall() 
2352 2338
                 if own['dropinCol'] == True:
2353 2339
                     own['requestAction'] = 'fak_dropin'
@@ -2357,9 +2343,7 @@ def main():
2357 2343
                     force = (linVelocity.x +1, linVelocity.y, linVelocity.z)
2358 2344
                     if own['dropinTimer'] == 0:
2359 2345
                         own.setLinearVelocity(force, True)                    
2360
-                #force = (linVelocity.x +1, linVelocity.y, linVelocity.z)
2361
-                #own.setLinearVelocity(force, True)
2362
-                #own['dropinTimer'] = 60
2346
+                        
2363 2347
         else:
2364 2348
             num = own['dropinTimer']
2365 2349
             if num > 0:
@@ -4312,9 +4296,7 @@ def main():
4312 4296
         linvelx = linVelocity.x
4313 4297
         lastx = own["linvelx"]
4314 4298
         wallsens = cont.sensors['wall']
4315
-        #print(wallsens.positive, 'wallsens')
4316 4299
         if frames_since_ground > 20 and (abs(lastx) - abs(linvelx)) > .5 and wallsens.positive:
4317
-            print('::::::wallhit')
4318 4300
             velx = linVelocity.x * -1.5
4319 4301
             if velx > 0 and velx < 1:
4320 4302
                 velx = 1
@@ -4351,7 +4333,7 @@ def main():
4351 4333
     air_mover()
4352 4334
     dropinRotate()    
4353 4335
     onboard()   
4354
-    wallhit() 
4336
+    #wallhit() 
4355 4337
     linvelx = own.getLinearVelocity(True)
4356 4338
     land_boost()
4357 4339
     own["linvelx"] = linvelx.x
@@ -4397,5 +4379,5 @@ def main():
4397 4379
         own.applyForce(force2, True)
4398 4380
     if (grindDar == False and r_ground.triggered and own['grindTouch'] == False) or own['jump_timer'] > 40:
4399 4381
         own['grindType'] = ''
4400
-   
4382
+        
4401 4383
     #print('q1:', q1oncd, 'q2:', q2oncd, 'q3:', q3oncd, 'q4:', q4oncd, 'q5:', q5oncd, 'q6:', q6oncd, 'q7:', q7oncd, 'q8:', q8oncd)     

+ 38
- 0
load_char.py View File

@@ -1,7 +1,34 @@
1 1
 
2 2
 import bge
3 3
 
4
+def ai(cont):  
5
+#    own = cont.owner
6
+#    scene = bge.logic.getCurrentScene()
7
+#    #actu = cont.actuators['start_level']
8
+#    dict = bge.logic.globalDict
9
+#    objList = scene.objects
10
+#    mainDir = bge.logic.expandPath("//")
11
+#    skater = 'ai_ed'
12
+#    
13
+#    fileName = mainDir + "npc_skaters/" + str(skater) + '.blend'    
14
+#    
15
+#    path = bge.logic.expandPath(fileName)
16
+#    bge.logic.LibLoad(path, 'Scene') 
17
+#    
18
+
19
+#    # get object named MainCharacter
20
+#    armature = objList["npc_ed_arm"]
21
+
22
+#    # combine child's shape with parent's
23
+#    compound = True
24
+
25
+#    # child is solid
26
+#    ghost = False
4 27
 
28
+#    # set parent
29
+#    armature.setParent( own, compound, ghost) 
30
+    
31
+    print('loading ai') 
5 32
 
6 33
 def main(cont):
7 34
     own = cont.owner
@@ -15,6 +42,15 @@ def main(cont):
15 42
     path = bge.logic.expandPath(fileName)
16 43
     bge.logic.LibLoad(path, 'Scene')  
17 44
     
45
+    fileName = mainDir + "assets/" + 'bmx_player' + '.blend'    
46
+    
47
+    path = bge.logic.expandPath(fileName)
48
+    bge.logic.LibLoad(path, 'Scene')     
49
+    fileName = mainDir + "assets/" + 'prop_bike.blend'    
50
+    
51
+    path = bge.logic.expandPath(fileName)
52
+    bge.logic.LibLoad(path, 'Scene') 
53
+    
18 54
     
19 55
 #    fileName = mainDir + "characters/sun.blend"    
20 56
 #    
@@ -23,3 +59,5 @@ def main(cont):
23 59
 
24 60
 
25 61
     cont.activate(actu)
62
+    
63
+        

+ 1
- 1
menuV3.py View File

@@ -2,7 +2,7 @@ import bge
2 2
 keyboard = bge.logic.keyboard
3 3
 JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
4 4
 
5
-player_list = ['annie', 'billy', 'fred', 'becky', 'kevin', 'ralph']               
5
+player_list = ['annie', 'billy', 'fred', 'becky', 'kevin', 'ralph', 'ed']               
6 6
 
7 7
 #exit functions
8 8
 #=======

+ 1
- 0
scene_init.py View File

@@ -172,6 +172,7 @@ def main():
172 172
     own['transition_timer'] = 0
173 173
     own['transitioning'] = 0
174 174
     own['driving'] = False
175
+    dict['last_driving'] = False
175 176
     own['last_roty'] = 0.0
176 177
        
177 178
 main()

+ 62
- 26
walk.py View File

@@ -57,7 +57,7 @@ ddPad = dict['ddPad']
57 57
 sens = .04
58 58
 fliplay = 30
59 59
 dropinCol = own.sensors['dropinCol']
60
-
60
+cube = scene.objects['control_cube.002']
61 61
 skater = scene.objects["Char4"]
62 62
 deck = scene.objects["deck"]
63 63
 trucks = scene.objects["trucks"]
@@ -81,8 +81,8 @@ cb_td = control_bottom.sensors['td_bottom']
81 81
 
82 82
 noidle = 0
83 83
 
84
-if skater.isPlayingAction(460):  
85
-    noidle = 1  
84
+#if skater.isPlayingAction(460):  
85
+#    noidle = 1  
86 86
 
87 87
 if own["stance"] == None:
88 88
     own["stance"] = True
@@ -315,9 +315,7 @@ def onboard():
315 315
         if own['framenum'] > 100 and own['fall'] == False:
316 316
             cont.activate(own.actuators['pop'])
317 317
         own['getoffboard'] = False
318
-        fliplay = 301
319
-        fliplay2 = 302 
320
-        fliplay3 = 303
318
+        own["walk_idle_frame"] = own["framenum"]
321 319
         own['grindcement_vol'] = 0
322 320
         own['grindcement_pitch'] = 0
323 321
         own['grindrail_vol'] = 0
@@ -333,15 +331,9 @@ def onboard():
333 331
             pass
334 332
          
335 333
         if STANCE == 0:
336
-            skater.stopAction(fliplay)
337
-            deck.stopAction(deckon)
338
-            trucks.stopAction(truckon)
339 334
             own['requestAction'] = 'reg_offboard'             
340 335
             
341 336
         if STANCE == 1:
342
-            skater.stopAction(fliplay)
343
-            deck.stopAction(deckon)
344
-            trucks.stopAction(truckon)
345 337
             own['requestAction'] = 'fak_offboard'                          
346 338
 def jump():
347 339
     #limit fall speed
@@ -374,11 +366,11 @@ def dropin():
374 366
     if dropinCol.positive == True:
375 367
         pass       
376 368
         
377
-def getonboard():
369
+def getonboard(dict):
378 370
     #print(dict['kb_q'])
379 371
     getonboard = own['getonboard']
380 372
     fliplay2 = 50#8560
381
-    if (yBut == True or dict['kb_q'] == 2) and cont.sensors["carNear"].positive == False:
373
+    if ((yBut == True and dict['last_yBut'] == False) or dict['kb_q'] == 2) and cont.sensors["vehicleNear"].positive == False:
382 374
         fliplay3 = fliplay2 + 1 
383 375
         if dropinCol.positive == True: 
384 376
             nearestObject = None
@@ -459,7 +451,7 @@ def getonboard():
459 451
         own['throw_deck'] = False 
460 452
         throw_deck_empty = scene.objects["throw_deck_empty"]
461 453
         throw_deck_empty['kill_deck'] = 1 
462
-    if ((yBut == False and lasty == True) or dict['kb_q'] == 3) and cont.sensors["carNear"].positive == False:               
454
+    if ((yBut == False and lasty == True) or dict['kb_q'] == 3) and cont.sensors["vehicleNear"].positive == False:               
463 455
         own['getonboard'] = 1 
464 456
         own['walk_idling'] = 0      
465 457
 
@@ -1060,14 +1052,31 @@ def onground():
1060 1052
             own['lF_ground_frame'] = own['framenum']
1061 1053
 
1062 1054
 def get_in_car():
1063
-    carNear = cont.sensors["carNear"]
1064
-    if carNear.positive:
1065
-        obj = carNear.hitObject
1055
+    vehicleNear = cont.sensors["vehicleNear"]
1056
+    #print('vh', vehicleNear.positive)
1057
+    scene = bge.logic.getCurrentScene()
1058
+    cam = scene.active_camera
1059
+    #dict = bge.logic.globalDict 
1060
+    if vehicleNear.positive and 'car' in vehicleNear.hitObject:
1061
+        obj = vehicleNear.hitObject
1066 1062
         if yBut == True:
1067 1063
             obj['driving'] = True
1068 1064
             own['driving'] = True
1069
-            scene = bge.logic.getCurrentScene()
1070
-            cam = scene.active_camera
1065
+            cube.suspendDynamics(True)
1066
+            cube.worldPosition = obj.worldPosition
1067
+            cube.worldOrientation = obj.worldOrientation
1068
+            rot = [ 0.0, 0.0, 1.570796327]
1069
+            cube.applyRotation(rot,False)            
1070
+            compound = False
1071
+
1072
+            # child is solid
1073
+            ghost = True
1074
+
1075
+            # set parent
1076
+            cube.setParent( obj, compound, ghost)            
1077
+            
1078
+            
1079
+
1071 1080
             #cam.target = obj
1072 1081
             #cam.state = 2
1073 1082
             cont.actuators['Camera'].object = obj
@@ -1075,12 +1084,38 @@ def get_in_car():
1075 1084
             cont.actuators['Camera'].min = 6
1076 1085
             cont.actuators['Camera'].max = 10
1077 1086
             own.state = 2
1078
-        print('near car')  
1087
+        print('near car')
1088
+        
1089
+    if dict['last_driving'] == True:
1090
+        cont.actuators['Camera'].object = scene.objects['camCube']    
1091
+        cont.activate(cont.actuators['walk'])               
1092
+    if own['driving'] == False:  
1093
+        #cont.actuators['Camera'].object = scene.objects['camCube'] 
1094
+        #cont.activate(cont.actuators['walk']) 
1095
+        dict['last_driving'] = False
1079 1096
         
1080
-def get_on_bike():
1081
-    bikeCol = cont.sensors['bikeCol']
1082
-    if bikeCol.positive and yBut == True:
1083
-        print('bike')                                          
1097
+def get_on_bike(dict, own):
1098
+    #bikeCol = cont.sensors['bikeCol']
1099
+    vehicleNear = cont.sensors["vehicleNear"]
1100
+    #print('vh', vehicleNear.positive)
1101
+    scene = bge.logic.getCurrentScene()
1102
+    #cam = scene.active_camera
1103
+    #dict = bge.logic.globalDict 
1104
+    if vehicleNear.positive and 'bike' in vehicleNear.hitObject:          
1105
+        if yBut == True and dict['last_yBut'] == False and own['throw_deck'] == True:
1106
+            vehicleNear.hitObject.endObject()
1107
+            dict['bike'] = True 
1108
+            cont.activate(own.actuators['bike_state']) 
1109
+
1110
+            object = "player_bike"
1111
+            # instantly add bullet
1112
+            newbike = scene.addObject(object, own, 0)
1113
+            #bike.localScale = 4.6            
1114
+            newbike.setParent(cube, False, False)
1115
+            #rot = [ 0.0, 0.0, 1.570796327]
1116
+            #bike.applyRotation(rot,False) 
1117
+            
1118
+                                              
1084 1119
                 
1085 1120
 onboard() 
1086 1121
 jump()
@@ -1089,7 +1124,7 @@ throwdeck_trigger()
1089 1124
 
1090 1125
 nextframe()
1091 1126
 checkidle()
1092
-getonboard()
1127
+getonboard(dict)
1093 1128
 reset_pos()
1094 1129
 switchcam()
1095 1130
 move_flycam()
@@ -1100,6 +1135,7 @@ sit()
1100 1135
 onground()
1101 1136
 focus_deck()
1102 1137
 get_in_car()
1138
+get_on_bike(dict, own)
1103 1139
 
1104 1140
 #printplaying() 
1105 1141
 

Loading…
Cancel
Save