shuvit 3 years ago
parent
commit
c3004cf0ff
4 changed files with 118 additions and 295 deletions
  1. 6
    0
      scripts/FSM.py
  2. 104
    29
      scripts/StatesPlayer.py
  3. 7
    0
      scripts/player.py
  4. 1
    266
      scripts/walk.py

+ 6
- 0
scripts/FSM.py View File

@@ -97,6 +97,12 @@ class PlayerFSM(Char):
97 97
         'Example',
98 98
         'Startup',
99 99
         'Walk',
100
+        'WalkJump',
101
+        'WalkAir',
102
+        'WalkLand',
103
+        'WalkHang',
104
+        'WalkClimb',
105
+        'WalkHurdle',
100 106
         'Roll']
101 107
         
102 108
         for s in state_list:

+ 104
- 29
scripts/StatesPlayer.py View File

@@ -29,7 +29,7 @@ class Example(State):
29 29
         
30 30
     def Execute(self):
31 31
         self.FSM.stateLife += 1
32
-        #self.FSM.ToTransition('toLand')
32
+        #self.FSM.ToTransition('toExample')
33 33
         
34 34
     def Exit(self):
35 35
         pass
@@ -65,21 +65,6 @@ class Walk(State):
65 65
     def Enter(self):
66 66
         self.FSM.stateLife = 1
67 67
         o = self.FSM.owner
68
-    
69
-        # if self.FSM.owner['stance']:
70
-        #     self.FSM.owner.applyRotation([0,0,3], True)
71
-        #     self.FSM.owner['stance'] = False
72
-        #     o['requestAction'] = 'fak_offboard' 
73
-        #     print('request fak offboard')            
74
-        # else:
75
-        #     o['requestAction'] = 'reg_offboard'                 
76
-        #     print('request reg offboard')            
77
-            #o['requestAction'] = 'fak_offboard'                          
78
-        
79
-        
80
-
81
-        
82
-
83 68
         super(Walk, self).Enter()        
84 69
         
85 70
     def Execute(self):
@@ -116,17 +101,7 @@ class Walk(State):
116 101
             o.linearVelocity.z = -10
117 102
         if dict['xBut'] == True or dict['kb_space'] == 1: 
118 103
             if dict['last_xBut'] == 0:
119
-                #killact(3)
120
-                #killact(4)
121
-                #killact(5)
122
-                #killact(6)
123
-                #killact(7)      
124
-                #if STANCE == 0:  
125 104
                 o['requestAction'] ='reg_jump'  
126
-                    #print('jump') 
127
-                #if STANCE == 1:
128
-                    #own['requestAction'] ='fak_jump'             
129
-                    #print('jump')
130 105
                 JUMPHEIGHT = 1100
131 106
                 force = [ 0.0, 0.0, JUMPHEIGHT]
132 107
                 # use local axis
@@ -135,16 +110,116 @@ class Walk(State):
135 110
                 if o.linearVelocity.z < 10:
136 111
                     o.applyForce(force, local)
137 112
                     o.linearVelocity.z += 5
138
-                    #o.linearVelocity.x = linvel.x
139
-                    #o.linearVelocity.y = linvel.y
140
-                    #own['walk_jump_timer'] = 6
113
+
114
+    def Exit(self):
115
+        pass
116
+
117
+
118
+#==================================== 
119
+            
120
+class WalkAir(State):
121
+    def __init__(self,FSM):
122
+        super(WalkAir, self).__init__(FSM)    
123
+        
124
+    def Enter(self):
125
+        self.FSM.stateLife = 1
126
+        super(WalkAir, self).Enter()        
141 127
         
128
+    def Execute(self):
129
+        self.FSM.stateLife += 1
130
+        #self.FSM.ToTransition('toLand')
131
+        
132
+    def Exit(self):
133
+        pass
142 134
 
135
+#==================================== 
136
+            
137
+class WalkJump(State):
138
+    def __init__(self,FSM):
139
+        super(WalkJump, self).__init__(FSM)    
140
+        
141
+    def Enter(self):
142
+        self.FSM.stateLife = 1
143
+        super(WalkJump, self).Enter()        
144
+        
145
+    def Execute(self):
146
+        self.FSM.stateLife += 1
147
+        #self.FSM.ToTransition('toLand')
148
+        
143 149
     def Exit(self):
144 150
         pass
145 151
 
146 152
 #==================================== 
147 153
             
154
+class WalkLand(State):
155
+    def __init__(self,FSM):
156
+        super(WalkLand, self).__init__(FSM)    
157
+        
158
+    def Enter(self):
159
+        self.FSM.stateLife = 1
160
+        super(WalkLand, self).Enter()        
161
+        
162
+    def Execute(self):
163
+        self.FSM.stateLife += 1
164
+        #self.FSM.ToTransition('toLand')
165
+        
166
+    def Exit(self):
167
+        pass
168
+
169
+#==================================== 
170
+            
171
+class WalkHang(State):
172
+    def __init__(self,FSM):
173
+        super(WalkHang, self).__init__(FSM)    
174
+        
175
+    def Enter(self):
176
+        self.FSM.stateLife = 1
177
+        super(WalkHang, self).Enter()        
178
+        
179
+    def Execute(self):
180
+        self.FSM.stateLife += 1
181
+        #self.FSM.ToTransition('toLand')
182
+        
183
+    def Exit(self):
184
+        pass
185
+
186
+#==================================== 
187
+            
188
+class WalkClimb(State):
189
+    def __init__(self,FSM):
190
+        super(WalkClimb, self).__init__(FSM)    
191
+        
192
+    def Enter(self):
193
+        self.FSM.stateLife = 1
194
+        super(WalkClimb, self).Enter()        
195
+        
196
+    def Execute(self):
197
+        self.FSM.stateLife += 1
198
+        #self.FSM.ToTransition('toLand')
199
+        
200
+    def Exit(self):
201
+        pass                                
202
+
203
+#==================================== 
204
+            
205
+class WalkHurdle(State):
206
+    def __init__(self,FSM):
207
+        super(WalkClimb, self).__init__(FSM)    
208
+        
209
+    def Enter(self):
210
+        self.FSM.stateLife = 1
211
+        super(WalkClimb, self).Enter()        
212
+        
213
+    def Execute(self):
214
+        self.FSM.stateLife += 1
215
+        #self.FSM.ToTransition('toLand')
216
+        
217
+    def Exit(self):
218
+        pass                                
219
+
220
+
221
+#==================================== 
222
+            
148 223
 class Roll(State):
149 224
     def __init__(self,FSM):
150 225
         super(Roll, self).__init__(FSM)    

+ 7
- 0
scripts/player.py View File

@@ -10,6 +10,13 @@ class Player:
10 10
 	def update(self):
11 11
 		self.FSM.Execute()
12 12
 
13
+	def get_ground_ray(self):
14
+		pass
15
+
16
+	def get_ground_dist(self, groundray):
17
+		pass
18
+
19
+
13 20
 def update(cont):
14 21
 	#print('-------------player updating----------------')
15 22
 	dict = bge.logic.globalDict

+ 1
- 266
scripts/walk.py View File

@@ -460,36 +460,7 @@ def main(cont):
460 460
                         if (minDist is None or dist < minDist):
461 461
                             nearestObject = obj
462 462
                             minDist = dist
463
-                # if nearestObject != None:
464
-                #     #print(nearestObject)
465
-                #     obj = nearestObject
466
-                #     player_e = own.worldOrientation.to_euler()
467
-                #     player_pos = own.worldPosition
468
-                #     player_rotz = math.degrees(player_e[2])                
469
-                #     grinder_e = obj.worldOrientation.to_euler()
470
-                #     grinder_rotz = math.degrees(grinder_e[2])            
471
-                #     rot = player_rotz - grinder_rotz  
472
-                #     grinder_pos = obj.worldPosition 
473
-                #     worldVect = [1, 0, 0]
474
-                #     vect = obj.getAxisVect(worldVect)      
475
-                #     go = obj.worldOrientation
476
-                #     grinder_axis = [1,0,0] 
477
-                #     try: 
478
-                #         delta = player_pos - grinder_pos
479
-                        
480
-                #         delta = delta.cross(vect)
481
-                #         if delta[2] >= 0:
482
-                #             grindside = "right"
483
-                #         else:
484
-                #             grindside = "left"                    
485
-                #         deltamove = delta[2] * .1#.25
486
-                #         if STANCE == 0:
487
-                #             move = [-deltamove, 0, 0]
488
-                #         else:
489
-                #             move = [deltamove, 0, 0]                            
490
-                #         own.applyMovement(move, True)                    
491
-                #     except:
492
-                #         pass 
463
+
493 464
                 print('dropin')
494 465
                 if STANCE == 0: 
495 466
                     own['requestAction'] ='reg_dropin' 
@@ -867,243 +838,7 @@ def main(cont):
867 838
             except:
868 839
                 pass    
869 840
                           
870
-    # def switchcam():
871
-    #     if ltsBut == False and own['lastlts'] == True and rtsBut == False:
872
-    #         if own['camera'] == 1:
873
-    #             own['camera'] = 0
874
-    #         else:
875
-    #             own['camera'] = 1
876
-    #     if rtsBut == False and own['lastrts'] == True and ltsBut == False:
877
-    #         if own['camera'] == 2:
878
-    #             own['camera'] = 0
879
-    #         else:
880
-    #             own['camera'] = 2 
881
-    # #followcam 
882
-    # def move_followcam():
883
-    #     if own['camera'] == 2:
884
-    #         if own['lastbkBut'] == True and bkBut == False:
885
-    #             #print("activate move followcam") 
886
-    #             if own['move_followcam'] == False:
887
-    #                 own['move_followcam'] = True
888
-    #             else:
889
-    #                 own['move_followcam'] = False                       
890
-    #         if own['move_followcam'] == True:
891
-    #             camspeed1 = .015
892
-    #             camspeed2 = .055
893
-    #             camrot1 = .005
894
-    #             camrot2 = .02
895
-    #             #up
896
-    #             if lUD < -0.080:
897
-    #                 followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
898
-    #                 cont.activate(followcam.actuators["up"])
899
-    #                 #print("fastup")
900
-    #             else:
901
-    #                 cont.deactivate(followcam.actuators["up"])    
902
-    # #            #down    
903
-    #             if lUD > .080:
904
-    #                 followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
905
-    #                 cont.activate(followcam.actuators["down"])
906
-    #             else:
907
-    #                 cont.deactivate(followcam.actuators["down"])                    
908
-    # #            #left
909
-    #             #if lLR < -0.080:
910
-    #             if lLR > 0.080:    
911
-    #                 followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]                
912
-    #                 cont.activate(followcam.actuators["left"])
913
-    #             else:
914
-    #                 cont.deactivate(followcam.actuators["left"])                    
915
-    # #            #right
916
-    #             #if lLR > 0.080: 
917
-    #             if lLR < -0.080:         
918
-    #                 followcam.actuators["right"].dLoc = [camspeed2, 0, 0]                
919
-    #                 cont.activate(followcam.actuators["right"])
920
-    #             else:
921
-    #                 cont.deactivate(followcam.actuators["right"])  
922
-    #             #up
923
-    #             if rUD < -0.080:
924
-    #                 followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
925
-    #                 cont.activate(followcam.actuators["rotup"])
926
-    #             else:
927
-    #                 cont.deactivate(followcam.actuators["rotup"])    
928
-    # #            #down    
929
-    #             if rUD > .080:
930
-    #                 followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]                
931
-    #                 cont.activate(followcam.actuators["rotdown"])
932
-    #             else:
933
-    #                 cont.deactivate(followcam.actuators["rotdown"])                    
934
-    # #            #left
935
-    #             if rLR < -0.080:
936
-    #                 followcam.actuators["rotleft"].dRot = [0, 0, camrot2]                
937
-    #                 cont.activate(followcam.actuators["rotleft"])
938
-    #             else:
939
-    #                 cont.deactivate(followcam.actuators["rotleft"])                    
940
-    # #            #right
941
-    #             if rLR > 0.080:         
942
-    #                 followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
943
-    #                 cont.activate(followcam.actuators["rotright"])
944
-    #             else:
945
-    #                 cont.deactivate(followcam.actuators["rotright"]) 
946
-
947
-    # #*********************************************                
948
-                    
949
-    #             if lUD > -0.080 and lUD < -0.030:
950
-    #                 followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
951
-    #                 cont.activate(followcam.actuators["up"])
952
-    #             else:
953
-    #                 cont.deactivate(followcam.actuators["up"])    
954
-    # #            #down    
955
-    #             if lUD < .080 and lUD > .03:
956
-    #                 followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]                
957
-    #                 cont.activate(followcam.actuators["down"])
958
-    #             else:
959
-    #                 cont.deactivate(followcam.actuators["down"])                    
960
-    # #            #left
961
-    #             if lLR > -0.080 and lLR < -0.030:
962
-    #                 followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]                
963
-    #                 cont.activate(followcam.actuators["left"])
964
-    #             else:
965
-    #                 cont.deactivate(followcam.actuators["left"])                    
966
-    # #            #right
967
-    #             if lLR < .080 and lLR > .03:       
968
-    #                 followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
969
-    #                 cont.activate(followcam.actuators["right"])
970
-    #             else:
971
-    #                 cont.deactivate(followcam.actuators["right"])  
972
-    #             #up
973
-    #             if rUD > -0.080 and rUD < -0.030:
974
-    #                 followcam.actuators["rotup"].dRot = [camrot1, 0, 0]                
975
-    #                 cont.activate(followcam.actuators["rotup"])
976
-    #             else:
977
-    #                 cont.deactivate(followcam.actuators["rotup"])    
978
-    # #            #down    
979
-    #             if rUD < .080 and rUD > .03:
980
-    #                 followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]                
981
-    #                 cont.activate(followcam.actuators["rotdown"])
982
-    #             else:
983
-    #                 cont.deactivate(followcam.actuators["rotdown"])                    
984
-    # #            #left
985
-    #             if rLR > -0.080 and rLR < -0.030:
986
-    #                 followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
987
-    #                 cont.activate(followcam.actuators["rotleft"])
988
-    #             else:
989
-    #                 cont.deactivate(followcam.actuators["rotleft"])                    
990
-    # #            #right
991
-    #             if rLR < .080 and rLR > .03:         
992
-    #                 followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
993
-    #                 cont.activate(followcam.actuators["rotright"])
994
-    #             else:
995
-    #                 cont.deactivate(followcam.actuators["rotright"])                       
996
-    # def move_flycam():
997
-    #     if own['camera'] == 1:
998
-    #         if own['lastbkBut'] == True and bkBut == False: 
999
-    #             if own['move_freecam'] == False:
1000
-    #                 own['move_freecam'] = True
1001
-    #             else:
1002
-    #                 own['move_freecam'] = False                       
1003
-    #         if own['move_freecam'] == True:
1004
-    #             camspeed1 = .015
1005
-    #             camspeed2 = .055
1006
-    #             camrot1 = .005
1007
-    #             camrot2 = .02
1008
-    #             #up
1009
-    #             if lUD < -0.080:
1010
-    #                 freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
1011
-    #                 cont.activate(freecam.actuators["up"])
1012
-    #             else:
1013
-    #                 cont.deactivate(freecam.actuators["up"])    
1014
-    # #            #down    
1015
-    #             if lUD > .080:
1016
-    #                 freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
1017
-    #                 cont.activate(freecam.actuators["down"])
1018
-    #             else:
1019
-    #                 cont.deactivate(freecam.actuators["down"])                    
1020
-    # #            #left
1021
-    #             if lLR < -0.080:
1022
-    #                 freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]                
1023
-    #                 cont.activate(freecam.actuators["left"])
1024
-    #             else:
1025
-    #                 cont.deactivate(freecam.actuators["left"])                    
1026
-    # #            #right
1027
-    #             if lLR > 0.080:         
1028
-    #                 freecam.actuators["right"].dLoc = [camspeed2, 0, 0]                
1029
-    #                 cont.activate(freecam.actuators["right"])
1030
-    #             else:
1031
-    #                 cont.deactivate(freecam.actuators["right"])  
1032
-    #             #up
1033
-    #             if rUD < -0.080:
1034
-    #                 freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
1035
-    #                 cont.activate(freecam.actuators["rotup"])
1036
-    #             else:
1037
-    #                 cont.deactivate(freecam.actuators["rotup"])    
1038
-    # #            #down    
1039
-    #             if rUD > .080:
1040
-    #                 freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]                
1041
-    #                 cont.activate(freecam.actuators["rotdown"])
1042
-    #             else:
1043
-    #                 cont.deactivate(freecam.actuators["rotdown"])                    
1044
-    # #            #left
1045
-    #             if rLR < -0.080:
1046
-    #                 freecam.actuators["rotleft"].dRot = [0, 0, camrot2]                
1047
-    #                 cont.activate(freecam.actuators["rotleft"])
1048
-    #             else:
1049
-    #                 cont.deactivate(freecam.actuators["rotleft"])                    
1050
-    # #            #right
1051
-    #             if rLR > 0.080:         
1052
-    #                 freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
1053
-    #                 cont.activate(freecam.actuators["rotright"])
1054
-    #             else:
1055
-    #                 cont.deactivate(freecam.actuators["rotright"]) 
1056
-
1057
-    # #*********************************************                
1058 841
                     
1059
-    #             if lUD > -0.080 and lUD < -0.030:
1060
-    #                 freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
1061
-    #                 cont.activate(freecam.actuators["up"])
1062
-    #                 #print(lUD)
1063
-    #             else:
1064
-    #                 cont.deactivate(freecam.actuators["up"])    
1065
-    # #            #down    
1066
-    #             if lUD < .080 and lUD > .03:
1067
-    #                 freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]                
1068
-    #                 cont.activate(freecam.actuators["down"])
1069
-    #             else:
1070
-    #                 cont.deactivate(freecam.actuators["down"])                    
1071
-    # #            #left
1072
-    #             if lLR > -0.080 and lLR < -0.030:
1073
-    #                 freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]                
1074
-    #                 cont.activate(freecam.actuators["left"])
1075
-    #             else:
1076
-    #                 cont.deactivate(freecam.actuators["left"])                    
1077
-    # #            #right
1078
-    #             if lLR < .080 and lLR > .03:       
1079
-    #                 freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
1080
-    #                 cont.activate(freecam.actuators["right"])
1081
-    #             else:
1082
-    #                 cont.deactivate(freecam.actuators["right"])  
1083
-    #             #up
1084
-    #             if rUD > -0.080 and rUD < -0.030:
1085
-    #                 freecam.actuators["rotup"].dRot = [camrot1, 0, 0]                
1086
-    #                 cont.activate(freecam.actuators["rotup"])
1087
-    #             else:
1088
-    #                 cont.deactivate(freecam.actuators["rotup"])    
1089
-    # #            #down    
1090
-    #             if rUD < .080 and rUD > .03:
1091
-    #                 freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]                
1092
-    #                 cont.activate(freecam.actuators["rotdown"])
1093
-    #             else:
1094
-    #                 cont.deactivate(freecam.actuators["rotdown"])                    
1095
-    # #            #left
1096
-    #             if rLR > -0.080 and rLR < -0.030:
1097
-    #                 freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
1098
-    #                 cont.activate(freecam.actuators["rotleft"])
1099
-    #             else:
1100
-    #                 cont.deactivate(freecam.actuators["rotleft"])                    
1101
-    # #            #right
1102
-    #             if rLR < .080 and rLR > .03:         
1103
-    #                 freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
1104
-    #                 cont.activate(freecam.actuators["rotright"])
1105
-    #             else:
1106
-    #                 cont.deactivate(freecam.actuators["rotright"])                     
1107 842
     if r_ground.triggered == False:
1108 843
         cont.deactivate(own.actuators["walk_align"])
1109 844
     else:

Loading…
Cancel
Save