Browse Source

small things

shuvit 1 week ago
parent
commit
4bd3f6571e

BIN
__pycache__/_version.cpython-36.pyc View File


BIN
__pycache__/configobj.cpython-36.pyc View File


+ 3
- 0
assets/bball.blend View File

@@ -0,0 +1,3 @@
1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:2621f61b99bfc8b588ae17492e5a8ccc53b06acd5a74fffc92dd522193ffb738
3
+size 497388

+ 0
- 3
assets/roads2.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:fe97724ac952f4c88647943afcd64ad67ef06a6c2f012f8c722a042278ceed2e
3
-size 82725548

+ 0
- 3
assets/roads3.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:eff3b3a843bfbbe32e0565b9828f15c81fa58c5c6f0f23ca9fd44f32d4542bde
3
-size 113150952

+ 0
- 3
assets/user2 - Copy.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:c50a27bf424176dd598105c13d29be8f773a6f580bdac498f8b29796ef9b2643
3
-size 63922652

BIN
assets/user2 - goodblend View File


+ 0
- 3
assets/user2_old.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:30554fe681901cd13de5a5ae3380bd83a5328f2909a95a1e5dc6ab34776cc51c
3
-size 4777216

+ 0
- 3
assets/user2_working.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:0d247901a62bb6010ba6b17b00746182abaf9567d11bd447f636d3367104a654
3
-size 5095432

+ 0
- 3
assets/user2_working_b.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:fe5bf37d0d69a9a6ce377ada85d078a1d299c7dfe1df40c26ca87a6e71ea5e6a
3
-size 5093604

+ 0
- 3
assets/user2bad.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:d4fc29e5e82b0f157ecdd700bc9122c2d45a86c449a3e5d5a90a934416272118
3
-size 64150232

+ 3
- 0
characters/annie-bak.blend View File

@@ -0,0 +1,3 @@
1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:35f66d89f9512a1d037c3fb0c370db0f541ea13f8c1fc162877a34177077e653
3
+size 4288452

BIN
custom_shaders/__pycache__/custom_shader_base.cpython-36.pyc View File


BIN
custom_shaders/__pycache__/custom_shader_utils.cpython-36.pyc View File


BIN
custom_shaders/__pycache__/wind.cpython-36.pyc View File


+ 0
- 3
roads.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:4fe769219c3ecc929016925b55fe2e6926287d93a921a569a61a4c45e2dbaa22
3
-size 82819680

+ 96
- 0
scripts/FSM.py View File

@@ -0,0 +1,96 @@
1
+import bge
2
+
3
+import StatesNpcPed
4
+import StatesCamera
5
+   
6
+#====================================
7
+class Transition(object):
8
+    def __init__(self, toState):
9
+        self.toState = toState
10
+    def Execute(self):
11
+        pass
12
+                        
13
+#===================================
14
+                        
15
+class FSM(object):
16
+    def __init__ (self, character, owner):
17
+        self.char = character
18
+        self.states = {}
19
+        self.transitions = {}
20
+        self.curState = None
21
+        self.prevState = None
22
+        self.trans = None
23
+        self.stateLife = 0
24
+        self.owner = owner
25
+        self.name = None
26
+        
27
+    def AddTransition(self, transName, transition):
28
+        self.transitions[transName] = transition
29
+    
30
+    def AddState(self, stateName, state):
31
+        self.states[stateName] = state
32
+        self.states[stateName].name = state        
33
+        
34
+    def SetState(self, stateName):
35
+        self.prevState = self.curState
36
+        self.curState = self.states[stateName]
37
+        
38
+    def ToTransition(self, toTrans):
39
+        self.trans = self.transitions[toTrans]
40
+        
41
+    def Execute(self, owner):
42
+        if (self.trans):
43
+            self.owner = owner
44
+            self.curState.Exit()
45
+            self.trans.Execute()
46
+            self.SetState(self.trans.toState)
47
+            self.curState.Enter()
48
+            self.trans = None        
49
+            
50
+        self.curState.Execute()    
51
+                
52
+#====================================
53
+
54
+Char = type("Char",(object,),{})
55
+
56
+#===================================
57
+        
58
+class NpcPed(Char):
59
+    def __init__(self, owner):
60
+        self.FSM = FSM(self, owner)
61
+        self.owner = owner
62
+        
63
+        state_list = [
64
+        'Example']
65
+        
66
+        for s in state_list:
67
+            self.FSM.AddState(s, getattr(StatesNpcPed, s)(self.FSM))
68
+            t = 'to' + s
69
+            self.FSM.AddTransition(t, Transition(s))
70
+        
71
+        if self.FSM.curState == None:
72
+            self.FSM.SetState('Example')
73
+    
74
+    def Execute(self):
75
+        self.FSM.Execute(self.owner)    
76
+        
77
+#=================================== 
78
+
79
+class CameraFSM(Char):
80
+    def __init__(self, owner):
81
+        self.FSM = FSM(self, owner)
82
+        self.owner = owner
83
+        
84
+        state_list = [
85
+        'Example']
86
+        
87
+        for s in state_list:
88
+            self.FSM.AddState(s, getattr(StatesCamera, s)(self.FSM))
89
+            t = 'to' + s
90
+            self.FSM.AddTransition(t, Transition(s))
91
+        
92
+        if self.FSM.curState == None:
93
+            self.FSM.SetState('Example')
94
+    
95
+    def Execute(self):
96
+        self.FSM.Execute(self.owner)    

+ 38
- 0
scripts/StatesCamera.py View File

@@ -0,0 +1,38 @@
1
+import utils
2
+import bge
3
+
4
+State = type("State", (object,), {})
5
+#====================================     
6
+class State(object):
7
+    def __init__(self, FSM):
8
+        self.FSM = FSM
9
+        self.timer = 0
10
+        self.startTime = 0
11
+    def Enter(self):
12
+        self.timer = 0
13
+        self.startTime = 0
14
+    def Execute(self):
15
+        print('Executing')
16
+    def Exit(self):
17
+        print('Exiting')
18
+#==================================== 
19
+            
20
+class Example(State):
21
+    def __init__(self,FSM):
22
+        super(Example, self).__init__(FSM)    
23
+        
24
+    def Enter(self):
25
+        self.FSM.stateLife = 1
26
+        super(Example, self).Enter()        
27
+        
28
+    def Execute(self):
29
+        self.FSM.stateLife += 1
30
+        #o = self.FSM.owner
31
+        #g = o.me['game']
32
+        #self.FSM.ToTransition('toNewState')
33
+        #print('cam fsm')
34
+    
35
+    def Exit(self):
36
+        pass
37
+
38
+#====================================  

+ 38
- 0
scripts/StatesNpcPed.py View File

@@ -0,0 +1,38 @@
1
+import utils
2
+import bge
3
+
4
+State = type("State", (object,), {})
5
+#====================================     
6
+class State(object):
7
+    def __init__(self, FSM):
8
+        self.FSM = FSM
9
+        self.timer = 0
10
+        self.startTime = 0
11
+    def Enter(self):
12
+        self.timer = 0
13
+        self.startTime = 0
14
+    def Execute(self):
15
+        print('Executing')
16
+    def Exit(self):
17
+        print('Exiting')
18
+#==================================== 
19
+            
20
+class Example(State):
21
+    def __init__(self,FSM):
22
+        super(Example, self).__init__(FSM)    
23
+        
24
+    def Enter(self):
25
+        self.FSM.stateLife = 1
26
+        super(Example, self).Enter()        
27
+        
28
+    def Execute(self):
29
+        self.FSM.stateLife += 1
30
+        #o = self.FSM.owner
31
+        #g = o.me['game']
32
+        #self.FSM.ToTransition('toNewState')
33
+        #print('npc fsm')
34
+    
35
+    def Exit(self):
36
+        pass
37
+
38
+#====================================  

+ 6
- 1
scripts/camera.py View File

@@ -6,6 +6,7 @@ scene = bge.logic.getCurrentScene()
6 6
 import camFSM
7 7
 import birds
8 8
 import sound_man
9
+import FSM
9 10
 
10 11
 def main(cont):
11 12
     #camFSM.main(cont)
@@ -63,6 +64,8 @@ def main(cont):
63 64
         dict['cam_state'] = 'walking'
64 65
         controlcube['ragdoll_active'] = False
65 66
         dict['camera'] = cam1
67
+        own['NpcPedFSM'] = FSM.NpcPed(own)
68
+        own['CamFSM'] = FSM.CameraFSM(own)
66 69
     acam = scene.active_camera
67 70
 
68 71
     def get_cam_state():
@@ -365,4 +368,6 @@ def main(cont):
365 368
     get_cam_state()
366 369
     camFSM.main(cont)
367 370
     birds.main(cont, scene)
368
-    sound_man.main(cont)
371
+    sound_man.main(cont)
372
+    own['NpcPedFSM'].Execute()
373
+    own['CamFSM'].Execute()

+ 5
- 77
scripts/walker_states.py View File

@@ -1,18 +1,14 @@
1 1
 import bge
2 2
 from random import randint
3 3
 from time import clock
4
-   
5
-   
4
+  
6 5
 #====================================
7 6
 class Transition(object):
8 7
 	def __init__(self, toState):
9 8
 		self.toState = toState
10 9
 	def Execute(self):
11
-		#print('Transitioning ...', self.toState)
12 10
 		pass
13
-			
14
-   
15
-   
11
+			   
16 12
 #====================================
17 13
 State = type("State", (object,), {})
18 14
 
@@ -23,27 +19,22 @@ class State(object):
23 19
 		self.startTime = 0
24 20
 	def Enter(self):
25 21
 		pass
26
-		#print('entering')
27 22
 	def Execute(self):
28 23
 		pass
29
-		#print('Executing')
30 24
 	def Exit(self):
31 25
 		pass
32
-		#print('Exiting')
33 26
 		
34 27
 class Target1(State):
35 28
 	def __init__(self,npcFSM):
36 29
 		super(Target1, self).__init__(npcFSM)    
37 30
 		
38 31
 	def Enter(self):
39
-		#print('Preparing to walk towards target 1.')
40 32
 		self.cont = bge.logic.getCurrentController()
41 33
 		self.npcFSM.stateLife = 1
42 34
 		self.own = self.cont.owner
43 35
 		self.target = 'larryTarget'
44 36
 		self.npcArm = self.own.children['npc']
45 37
 		self.scene = bge.logic.getCurrentScene()
46
-		
47 38
 
48 39
 		nm = self.own['navMesh']
49 40
 		self.pt = nm.findPath(self.own.worldPosition, self.scene.objects[self.target].worldPosition)
@@ -52,10 +43,8 @@ class Target1(State):
52 43
 		super(Target1, self).Enter()
53 44
 		
54 45
 	def Execute(self):
55
-		#print('Tracking target 1.', self.npcFSM.stateLife)
56 46
 		self.npcFSM.stateLife += 1
57 47
 		duration = 50000
58
-		#print('path', self.pt)
59 48
 
60 49
 		if len(self.pt) > 0:
61 50
 			target = self.pt[0]
@@ -76,24 +65,12 @@ class Target1(State):
76 65
 			print('goal reached')	
77 66
 			self.npcFSM.ToTransition('toTarget2')	
78 67
 
79
-
80
-
81
-
82 68
 		if self.npcFSM.stateLife > duration:
83 69
 			num = randint(1,2)
84
-			# if num == 1:
85
-			# 	self.npcFSM.ToTransition('toTarget2')
86
-			# elif num ==2:
87
-			# 	self.npcFSM.ToTransition('toTarget2')	
88
-			# else:
89
-			# 	self.npcFSM.ToTransition('toIdle')
90 70
 		else:	
91
-			#self.cont.activate(self.actu)	
92 71
 			self.npcArm.playAction('g_walk2', 1,62, layer=2, play_mode=0, speed=.5)			
93 72
 			
94 73
 	def Exit(self):
95
-		#print('Finished target 1') 
96
-		#self.cont.deactivate(self.actu) 
97 74
 		pass	
98 75
 
99 76
 class Target2(State):
@@ -101,7 +78,6 @@ class Target2(State):
101 78
 		super(Target2, self).__init__(npcFSM)    
102 79
 		
103 80
 	def Enter(self):
104
-		#print('Preparing to walk towards target 2.')
105 81
 		self.cont = bge.logic.getCurrentController()
106 82
 		self.npcFSM.stateLife = 1
107 83
 		self.own = self.cont.owner
@@ -115,12 +91,9 @@ class Target2(State):
115 91
 		super(Target2, self).Enter()
116 92
 		
117 93
 	def Execute(self):
118
-		#print('Tracking target 2.', self.npcFSM.stateLife)
119 94
 		self.npcFSM.stateLife += 1
120 95
 		duration = 10000
121 96
 
122
-
123
-
124 97
 		if len(self.pt) > 0:
125 98
 			target = self.pt[0]
126 99
 			vg = self.own.getVectTo(target)
@@ -128,7 +101,6 @@ class Target2(State):
128 101
 			v = vg[1]
129 102
 			self.own.alignAxisToVect(v, 0, .5)
130 103
 			self.own.alignAxisToVect([0,0,1], 2, 1)
131
-			#print(dist)
132 104
 			if dist > 1.5:
133 105
 				x = 10
134 106
 				max_vel = 1.5
@@ -142,20 +114,11 @@ class Target2(State):
142 114
 
143 115
 		if self.npcFSM.stateLife > duration:
144 116
 			num = randint(1,3)
145
-			# if num == 1:
146
-			# 	self.npcFSM.ToTransition('toTarget3')
147
-			# elif num ==2:
148
-			# 	self.npcFSM.ToTransition('toTarget3')	
149
-			# else:
150
-			# 	self.npcFSM.ToTransition('toIdle')
151 117
 		else:		
152
-			#self.cont.activate(self.actu)
153 118
 			self.npcArm.playAction('g_walk2', 1,62, layer=2, play_mode=0, speed=.5)			
154 119
 							
155 120
 				
156 121
 	def Exit(self):
157
-		#print('Finished target 2') 
158
-		#self.cont.deactivate(self.actu)          
159 122
 		pass
160 123
 		
161 124
 class Target3(State):
@@ -163,7 +126,6 @@ class Target3(State):
163 126
 		super(Target3, self).__init__(npcFSM)    
164 127
 		
165 128
 	def Enter(self):
166
-		#print('Preparing to walk towards target 3.')
167 129
 		self.cont = bge.logic.getCurrentController()
168 130
 		self.npcFSM.stateLife = 1
169 131
 		self.own = self.cont.owner
@@ -173,7 +135,7 @@ class Target3(State):
173 135
 		
174 136
 		nm = self.own['navMesh']
175 137
 		self.pt = nm.findPath(self.own.worldPosition, self.scene.objects[self.target].worldPosition)
176
-		
138
+
177 139
 		print('target3')
178 140
 		super(Target3, self).Enter()
179 141
 
@@ -213,8 +175,6 @@ class Target3(State):
213 175
 			
214 176
 
215 177
 	def Exit(self):
216
-		#print('Finished target 3') 
217
-		#self.cont.deactivate(self.actu)              
218 178
 		pass
219 179
 		
220 180
 		
@@ -224,7 +184,6 @@ class Idle(State):
224 184
 		super(Idle, self).__init__(npcFSM)  
225 185
 		
226 186
 	def Enter(self):
227
-		#print('Starting to idle.')
228 187
 		self.cont = bge.logic.getCurrentController()
229 188
 		self.own = self.cont.owner
230 189
 		self.npcArm = self.own.children['npc']
@@ -233,33 +192,16 @@ class Idle(State):
233 192
 		super(Idle, self).Enter()
234 193
 		
235 194
 	def Execute(self):
236
-		#print('Idleing.', self.npcFSM.stateLife)
237 195
 		self.npcFSM.stateLife += 1
238 196
 		duration = 300
239 197
 		if self.npcFSM.stateLife > duration:
240 198
 			num = randint(1,4)
241
-			#self.npcFSM.ToTransition('toImpatient')
242 199
 			self.npcFSM.ToTransition('toTarget1')
243
-			# if num == 1:
244
-			# 	self.npcFSM.ToTransition('toTarget1')
245
-			# elif num == 2:
246
-			# 	self.npcFSM.ToTransition('toTarget2')	
247
-			# elif num == 3:
248
-			# 	self.npcFSM.ToTransition('toTarget3')
249
-			# elif num == 4 or num == 5 or num == 6:
250
-			# 	self.npcFSM.ToTransition('toImpatient')										
251
-			# else:
252
-			# 	self.npcFSM.ToTransition('toIdle')
253 200
 		else:
254
-			#pass
255
-			#print(self.own.children)
256
-			#print('idling')
257 201
 			self.npcArm.playAction('g_idle', 1,201, layer=2, play_mode=0, speed=.5)	
258 202
 			
259 203
 	def Exit(self):
260 204
 		pass
261
-		##print('Waking up from idle.') 
262
-
263 205
 
264 206
 class Startup(State):
265 207
 	
@@ -288,7 +230,6 @@ class Impatient(State):
288 230
 		super(Impatient, self).__init__(npcFSM)  
289 231
 		
290 232
 	def Enter(self):
291
-		#print('Starting to idle.')
292 233
 		self.npcFSM.stateLife = 1
293 234
 		self.cont = bge.logic.getCurrentController()
294 235
 		self.own = self.cont.owner
@@ -296,7 +237,6 @@ class Impatient(State):
296 237
 		super(Impatient, self).Enter()
297 238
 		
298 239
 	def Execute(self):
299
-		#print('being Impatient.', self.npcFSM.stateLife)
300 240
 		self.npcFSM.stateLife += 1
301 241
 		duration = 300
302 242
 		if self.npcFSM.stateLife > duration:
@@ -306,9 +246,7 @@ class Impatient(State):
306 246
 			self.npcArm.playAction('npcImpatient', 1,201, layer=2, play_mode=0, speed=.5)	
307 247
 			
308 248
 	def Exit(self):
309
-		pass
310
-		#print('stopping bening impatient.') 		         
311
-						   
249
+		pass				   
312 250
 					 
313 251
 #===================================
314 252
 						
@@ -351,9 +289,6 @@ Char = type("Char",(object,),{})
351 289
 class Walker(Char):
352 290
 	def __init__(self):
353 291
 		self.npcFSM = npcFSM(self)
354
-		#cont = bge.logic.getCurrentController()
355
-		#own = cont.owner
356
-		#self.LightOn = own['state']
357 292
 		
358 293
 		##STATES
359 294
 		self.npcFSM.AddState("Startup", Startup(self.npcFSM))
@@ -374,12 +309,10 @@ class Walker(Char):
374 309
 		
375 310
 		if self.npcFSM.curState == None:
376 311
 			self.npcFSM.SetState('Startup')
377
-			#self.npcFSM.ToTransition('toIdle')
378
-			#print('setting npc state to startup')
379 312
 	
380 313
 	def Execute(self):
381 314
 		self.npcFSM.Execute()    
382
-		#print('executing machine')
315
+
383 316
 #====================================     
384 317
 r = Walker()
385 318
 def main(cont):
@@ -394,7 +327,6 @@ def main(cont):
394 327
 		for x in scene.objects:
395 328
 			if 'npcNavmesh' in x:
396 329
 				own['navMesh'] = x
397
-		#print('initing')
398 330
 
399 331
 	if own['frame'] == 40:
400 332
 		own.worldPosition = [0,0,50]	
@@ -404,12 +336,8 @@ def main(cont):
404 336
 			to = scene.objects[ln]	
405 337
 			own.worldPosition = to.worldPosition
406 338
 			own.worldOrientation = to.worldOrientation
407
-			#own.worldPosition.z += 50
408
-
409 339
 
410 340
 	r.Execute()    
411
-	#print(r.npcFSM.curState)
412
-
413 341
 
414 342
 	own['frame'] += 1
415 343
 	yvel = own.linearVelocity.y

BIN
six/__pycache__/__init__.cpython-36.pyc View File


BIN
six/__pycache__/six.cpython-36.pyc View File


BIN
tinytag/__pycache__/__init__.cpython-36.pyc View File


BIN
tinytag/__pycache__/tinytag.cpython-36.pyc View File


Loading…
Cancel
Save