Browse Source

moving scripts folder

shuvit 5 years ago
parent
commit
6a96bfdc1a

+ 129
- 0
scripts/DList.py View File

1
+""" A node is a container which encapsulates any type of data.
2
+    The node object also has a reference to the NODE preceding and following
3
+    said object."""
4
+class Node(object):
5
+ 
6
+    def __init__(self, data, prev, next):
7
+        self.data = data
8
+        self.prev = prev
9
+        self.next = next
10
+        
11
+    def getNext(self):
12
+        if self.next is not None:
13
+            return self.next
14
+        print('There\'s nothing next, trying prev')
15
+        if self.prev is not None:
16
+            return self.prev
17
+        print('There\s nothing before either, just this one')
18
+        return self
19
+        
20
+    def getPrev(self):
21
+        if self.prev is not None:
22
+            return self.prev
23
+        print('There\'s nothing before, trying next')
24
+        if self.next is not None:
25
+            return self.next
26
+        print('There\'s nothing next either, just this one')
27
+        return self
28
+        
29
+    def getData(self):
30
+        return self.data
31
+ 
32
+""" A doubly-linked list implementation 
33
+    NOTE: the getters and setters return a reference to a Node object,
34
+    inside which is the data you're probably looking for. If you want to
35
+    access data, remember; after you call a get or find, use .data"""
36
+class DoubleList(object):
37
+ 
38
+    head = None
39
+    tail = None
40
+    length = 0;
41
+ 
42
+    """ Add a node to the list """
43
+    def append(self, data):
44
+        new_node = Node(data, None, None)
45
+        if self.head is None:
46
+            self.head = self.tail = new_node
47
+        else:
48
+            new_node.prev = self.tail
49
+            new_node.next = None
50
+            self.tail.next = new_node
51
+            self.tail = new_node
52
+        self.length = self.length + 1
53
+ 
54
+    """ Find a node in the list, then remove it """
55
+    def remove(self, node):
56
+        current_node = self.head
57
+ 
58
+        while current_node is not None:
59
+            if current_node == node:
60
+                # if it's not the first element
61
+                if current_node.prev is not None:
62
+                    current_node.prev.next = current_node.next
63
+                    current_node.next.prev = current_node.prev
64
+                # if its the last element
65
+                elif current_node.next is None:
66
+                    self.tail = current_node.prev
67
+                    self.tail.prev = current_node.prev.prev
68
+                    self.tail.next = None
69
+                else:
70
+                    # otherwise we have no prev (it's None), head is the next one, and prev becomes None
71
+                    self.head = current_node.next
72
+                    current_node.next.prev = None
73
+ 
74
+            current_node = current_node.next
75
+        self.length = self.length - 1
76
+    
77
+    def show(self):
78
+        print("Show list data:")
79
+        current_node = self.head
80
+        while current_node is not None:
81
+            print(current_node.data)
82
+            current_node = current_node.next
83
+        print("*"*50)
84
+        
85
+    """ Find a node in the list by value comparison """
86
+    def findNode(self, node_value):
87
+        current_node = self.head
88
+        
89
+        while current_node is not None:
90
+            if current_node.data == node_value:
91
+                return current_node
92
+            current_node = current_node.next
93
+    
94
+    """ Get a node by index position """
95
+    def get(self, index):
96
+        if index > self.length:
97
+            return none
98
+        elif index == 1:
99
+            return self.head
100
+        elif index == self.length:
101
+            return self.tail
102
+        else:
103
+            current_node = self.head
104
+            pos = 1
105
+            while pos < index:
106
+                current_node = current_node.next
107
+                pos = pos + 1
108
+            return current_node
109
+    
110
+    """ Checks if a node is in this list """
111
+    def contains(self, node):
112
+        current_node = self.head
113
+        while current_node is not None:
114
+            if current_node == node:
115
+                return true
116
+            current_node = current_node.next
117
+        return false
118
+        
119
+    """ Get the length of this list """
120
+    def getLength(self):
121
+        return self.length
122
+        
123
+    """ Get the head of this list """
124
+    def getHead(self):  # get head (;
125
+        return self.head
126
+        
127
+    """ Get the tail of this list """
128
+    def getTail(self):
129
+        return self.tail

+ 596
- 0
scripts/Manager.py View File

1
+def main():
2
+
3
+    #"""
4
+    #Modified BGE Gameplay Recorder Version 2
5
+    #originally written by Nicholas Anderson, aka Red Frost Games.
6
+    #"""
7
+
8
+    #####Tweakables###############
9
+    #Watch out! These numbers might bite!
10
+    frame_rate = 60    #Set this to the framerate of your game.
11
+    optimization = 1    #An integer, must be at least 1! Higher value will make a smaller saved file size. I do not reccomend setting it to anything other than 1 though.
12
+    recording_cutoff = 7300 #3600   #Frames at which the oldest recorded frame will be deleted. 0 is no cutoff.
13
+    recorder_state = 1   #This is the main state of the recorder object. State will be reverted to this value when the user breaks out of the playback.
14
+    allow_playback_break = True   #Allow the player to resume playing from the position in the recording.
15
+    #####Sensor names#############
16
+    record_sensor = "Record"
17
+    save_recording_sensor = "Save"
18
+    load_recording_sensor = "Load"
19
+    track_left_sensor = "Left"
20
+    track_right_sensor = "Right"
21
+    break_sensor = "Break"
22
+    ##############################
23
+
24
+    from bge import logic
25
+    import Record
26
+    import SortData
27
+
28
+    cont = logic.getCurrentController()
29
+    own = cont.owner
30
+
31
+    cont.sensors[record_sensor].skippedTicks = optimization
32
+    dict = logic.globalDict
33
+
34
+    #dict['recorder_on'] = recorder_on
35
+    recorder_on = dict.get('recorder_on')
36
+    own['recorder_on'] = recorder_on
37
+    #print("recorder on: ", recorder_on) 
38
+
39
+    if recorder_on == 1:
40
+        #----
41
+        scene = logic.getCurrentScene()
42
+        scene_list = logic.getSceneList()
43
+        camList = scene.cameras
44
+        followcam = camList["followcam"]
45
+        freecam = camList["freecam"]
46
+        skater = scene.objects["Char4"]
47
+        cube = scene.objects["control_cube.002"]
48
+        deck = scene.objects["deck"]
49
+        trucks = scene.objects["trucks"]
50
+        replay_cam_axis = own['replay_cam_axis']
51
+        cam = own.actuators['Camera']
52
+        #----
53
+        joybutsens = "joyBut"
54
+        #butt = cont.sensors[joybutsens]
55
+        #aXis = cont.sensors["joysticksens"]
56
+        #bk_but = 4
57
+        back_on = dict['bkBut']
58
+        #a_but = 0
59
+        a_on = dict['aBut']
60
+        #b_but = 1
61
+        b_on = dict['bBut']
62
+        #print(a on)
63
+        last_back = own['last_back_but']
64
+        #last_back = own['last_a_but']
65
+    #    reduction = 400000
66
+    #    axisTh = 0.03 
67
+    #    lt = 4
68
+    #    rt = 5
69
+    #    lts_pr = 7
70
+    #    rts_pr = 8
71
+
72
+    #    lar_lts = 0
73
+    #    uad_lts = 1
74
+    #    lar_rts = 2 
75
+    #    uad_rts = 3 
76
+        #lts_pr = 7
77
+        #rts_pr = 8
78
+    #    lTrig = aXis.axisValues[lt] / reduction
79
+    #    rTrig = aXis.axisValues[rt] / reduction
80
+    #    lLR = aXis.axisValues[lar_lts] / reduction
81
+    #    lUD = aXis.axisValues[uad_lts] / reduction
82
+    #    rLR = aXis.axisValues[lar_rts] / reduction
83
+    #    rUD = aXis.axisValues[uad_rts] / reduction
84
+    #    ltsBut = butt.getButtonStatus(lts_pr)
85
+    #    rtsBut = butt.getButtonStatus(rts_pr) 
86
+    #        
87
+        lLR = dict['lLR']
88
+        lUD = dict['lUD']
89
+        rLR = dict['rLR']
90
+        rUD = dict['rUD']
91
+        lTrig = dict['lTrig']
92
+        rTrig = dict['rTrig']
93
+        aBut = dict['aBut']
94
+        bBut = dict['bBut']
95
+        xBut = dict['xBut']
96
+        yBut = dict['yBut']
97
+        lBump = dict['lBump']
98
+        rBump = dict['rBump']
99
+        bkBut = dict['bkBut']
100
+        stBut = dict['stBut']
101
+        xbBut = dict['xbBut']
102
+        ltsBut = dict['ltsBut']
103
+        rtsBut = dict['rtsBut']
104
+        ldPad = dict['ldPad']
105
+        rdPad = dict['rdPad']
106
+        udPad = dict['udPad']
107
+        ddPad = dict['ddPad']    
108
+            
109
+        try:
110
+            pause_state = dict['npause']
111
+            last_pause = dict['last_npause']
112
+        except:
113
+            dict['npause'] = 0
114
+            dict['last_npause'] = 0
115
+            pause_state = 0
116
+            last_pause = 0          
117
+           
118
+        #trigs results range 0 - .08
119
+        #print(lTrig, rTrig)
120
+
121
+        #if cont.sensors[record_sensor].positive:
122
+        if own["playback"] != True:    
123
+            Record.main(recording_cutoff, cube)
124
+            
125
+        if cont.sensors[save_recording_sensor].positive:
126
+            SortData.writeData.saveAll()
127
+            
128
+        #if cont.sensors[load_recording_sensor].positive or (cube["sel"] == 1 and cube["last_sel"] == 0):
129
+        if own['back_state'] == 1 and back_on == 1 and last_back == 0:
130
+            cube["last_sel"] == 1
131
+            SortData.writeData.saveAll()
132
+            own["playback"] = True
133
+            own["playbackBroken"] = False
134
+            freecam.worldPosition = own.worldPosition
135
+            followcam.worldPosition = own.worldPosition
136
+            cube['grindcement_vol'] = 0
137
+            cube['grindcement_pitch'] = 0
138
+            cube['grindrail_vol'] = 0
139
+            cube['grindrail_pitch'] = 0 
140
+            cube['sroll_vol'] = 0
141
+            cube['sroll_pitch'] = 0             
142
+            
143
+
144
+        if own["playback"]:
145
+            Record.loadData()
146
+        #..................
147
+        if cont.sensors[track_left_sensor].positive:
148
+            own["objIndex"] -= 2
149
+            logic.setLogicTicRate(frame_rate*own["playbackSpeed"])
150
+            
151
+        if cont.sensors[track_right_sensor].positive:
152
+            own["objIndex"] += 2
153
+            logic.setLogicTicRate(frame_rate*own["playbackSpeed"])
154
+
155
+        if own["playback"] == True:    
156
+            if rTrig > .01 and rTrig < .02:
157
+                own["objIndex"] += 2
158
+                logic.setLogicTicRate(frame_rate*.5) 
159
+            if (rTrig >= .02 and rTrig < .06) or own['loop_play'] == 1:
160
+                own["objIndex"] += 2
161
+                logic.setLogicTicRate(frame_rate*1)
162
+                #print(own['objIndex'])
163
+            if rTrig >= .06 and rTrig < .09:
164
+                own["objIndex"] += 2
165
+                logic.setLogicTicRate(frame_rate*1.5) 
166
+            if lTrig > .01 and lTrig < .02:
167
+                own["objIndex"] -= 2
168
+                logic.setLogicTicRate(frame_rate*.5) 
169
+            if lTrig >= .02 and lTrig < .06:
170
+                own["objIndex"] -= 2
171
+                logic.setLogicTicRate(frame_rate*1)
172
+            if lTrig >= .06 and lTrig < .09:
173
+                if own['loop_play'] == 1:
174
+                    own["objIndex"] -= 6
175
+                    #logic.setLogicTicRate(frame_rate*1.5)
176
+                else:    
177
+                    own["objIndex"] -= 2
178
+                    logic.setLogicTicRate(frame_rate*1.5)
179
+            if b_on == True and pause_state == 0:
180
+                #print("bbut_on")
181
+                own['objIndex'] = 0
182
+                own['valueIndex'] = 0 
183
+                logic.setLogicTicRate(frame_rate*1)                       
184
+
185
+        #....................
186
+        if allow_playback_break:
187
+
188
+            if own['back_state'] == 0 and back_on == 1 and last_back == 0:       
189
+                own["playbackBroken"] = True
190
+                own["playback"] = False
191
+                #print("break - add hud, remove stance (back_state == False)")
192
+                #cont.activate(own.actuators['add_hud'])
193
+                #cont.activate(own.actuators['remove_stance'])
194
+                #removescene = cont.actuators["remove_hud"]
195
+                #removescene.scene = "replay_HUD"
196
+                #addscene = cont.actuators["add_hud"]
197
+                #addscene.scene = "stance"
198
+                #cont.activate(addscene)        
199
+                #cont.activate(removescene)
200
+            elif own["playbackBroken"] and back_on == 0:
201
+                Record.breakOut()
202
+                #cont.activate(own.actuators['remove_hud'])
203
+                #cont.activate(own.actuators['add_stance'])
204
+                #addscene = cont.actuators["add_hud"]
205
+                #addscene.scene = "replay_HUD"
206
+                #removescene = cont.actuators["remove_hud"]
207
+                #removescene.scene = "stance"
208
+                #cont.activate(addscene)
209
+                #cont.activate(removescene)
210
+                
211
+                logic.setLogicTicRate(frame_rate)
212
+                #set value index
213
+                own.state = recorder_state
214
+                own["playbackBroken"] = False
215
+                skater.stopAction(9999)
216
+                deck.stopAction(9999)
217
+                trucks.stopAction(9999)
218
+                cont.activate(own.actuators['replayCam'])
219
+                #print("unbreak")
220
+                own['loop_play'] = 0
221
+                #own['valueIndex'] = 0
222
+                #own["objIndex"] += 2
223
+                #logic.setLogicTicRate(frame_rate*1)
224
+                #own['objectIndex'] = 0
225
+                #print("valueIndex = ", own['valueIndex'])
226
+        if back_on == 1 and own['back_but'] == 0:
227
+            #print("change back state")
228
+            if own['back_state'] == True:
229
+                own['back_state'] = False
230
+            #elif own['back_state'] == False:
231
+            else:
232
+                own['back_state'] = True
233
+    ###
234
+        if own['last_playback'] != own['playback']:
235
+            if own['last_playback'] == True:
236
+                cont.activate(own.actuators['remove_hud'])
237
+                cont.activate(own.actuators['add_stance']) 
238
+                own['camnum'] = 0
239
+                cam = camList["Camera.003"]
240
+                scene.active_camera = cam                        
241
+                #print("turning replay off", own['playback'])
242
+                
243
+              
244
+            if own['last_playback'] == False:
245
+                #print("turning replay on", own['playback'])
246
+                cont.activate(own.actuators['add_hud'])
247
+                cont.activate(own.actuators['remove_stance'])
248
+                own['objIndex'] = 0
249
+                own['valueIndex'] = 3
250
+                logic.setLogicTicRate(frame_rate*1)  
251
+                
252
+                
253
+              
254
+                
255
+        if dict['rtsBut'] == False and dict['last_rtsBut'] == True and own['playback'] == True:
256
+            
257
+            if 'pause' in scene_list:    
258
+                #cont.activate(own.actuators['remove_overlay']) 
259
+                cont.activate(own.actuators['add_hud'])
260
+            else:
261
+                #cont.activate(own.actuators['add_overlay']) #pause
262
+                cont.activate(own.actuators['remove_hud']) #replay 
263
+                cont.activate(own.actuators['pause_replay_remove']) 
264
+                                            
265
+        if pause_state == 1 and last_pause == 1 and own["playback"]:
266
+            #print('pause_on')
267
+            if 'pause_replay' not in scene_list:
268
+                cont.activate(own.actuators['pause_replay_add'])
269
+                #print('pause_on')
270
+                
271
+        if pause_state != 1 and own["playback"]:
272
+            if 'pause_replay' in scene_list:
273
+                cont.activate(own.actuators['pause_replay_remove'])                    
274
+        if own['playback'] and 'pause' in scene_list:
275
+            cont.activate(cube.actuators['remove_overlay'])                         
276
+                             
277
+    ####
278
+        if a_on == 1 and own['a_but'] == False and pause_state == 0:
279
+            if own['loop_play'] == 1:
280
+                own['loop_play'] = 0
281
+            else:
282
+                own['loop_play'] = 1            
283
+        if rLR > .05 and own["playback"]:
284
+            act = cont.actuators["replayCam"]
285
+            if rLR > .07:
286
+                act.dLoc = [ .06, 0.0, 0.0]
287
+            else:
288
+                act.dLoc = [ .03, 0.0, 0.0]
289
+            #cont.deactivate(own.actuators['Camera'])
290
+            cont.activate(own.actuators['replayCam']) 
291
+            #print("move") 
292
+        elif rLR < -.05 and own["playback"]:
293
+            act = cont.actuators["replayCam"]
294
+            if rLR < -.07:
295
+                act.dLoc = [ -.06, 0.0, 0.0]
296
+            else:    
297
+                act.dLoc = [ -.03, 0.0, 0.0]
298
+            #cont.deactivate(own.actuators['Camera'])
299
+            #act.damping = 6
300
+            cont.activate(own.actuators['replayCam']) 
301
+            #print("move")         
302
+        else:  
303
+            #pass      
304
+            cont.deactivate(own.actuators['replayCam'])
305
+            #cont.activate(own.actuators['Camera'])
306
+        #print("back state: ", own['back_state'], "last_back_but: ", own['last_back_but'], "back_but :", own['back_but'])  
307
+        #integer
308
+        # 
309
+        #0 = +X axis
310
+        # 
311
+        #1 = +Y axis
312
+        # 
313
+        #2 = +Z axis
314
+        # 
315
+        #3 = -X axis
316
+        # 
317
+        #4 = -Y axis
318
+        # 
319
+        #5 = -Z axis
320
+    #    if rLR > .05 and own["playback"]:
321
+    #        if own['last_rtsBut'] == True and rtsBut == False:
322
+    #            if replay_cam_axis == 0:
323
+    #               replay_cam_axis = 1
324
+    #            elif replay_cam_axis == 1:
325
+    #                replay_cam_axis = 3
326
+    #            elif replay_cam_axis == 3 :
327
+    #                replay_cam_axis = 4
328
+    #            elif replay_cam_axis == 4:
329
+    #                replay_cam_axis = 0 
330
+    #        cam.axis = replay_cam_axis
331
+    #        cont.activate(cam)
332
+    #        print("set replay_cam_axis: ", replay_cam_axis)
333
+    #        own['replay_cam_axis'] = replay_cam_axis
334
+        if own['last_ltsBut'] == True and ltsBut == False and own['playback']:
335
+            # get camera named SecurityCam
336
+            if own['camnum'] == 1:
337
+                own['camnum'] = 2
338
+            elif own['camnum'] == 0:
339
+                own['camnum'] = 1 
340
+            elif own['camnum'] == 2:
341
+                own['camnum'] = 0    
342
+        if own['last_rtsBut'] == True and rtsBut == False and own['playback']:
343
+            # get camera named SecurityCam
344
+            if "replay_HUD" in scene_list:
345
+                cont.activate(own.actuators['remove_hud'])
346
+            else:
347
+                cont.activate(own.actuators['add_hud'])
348
+        if own['camnum'] == 1 and own['playback']:
349
+            
350
+            scene.active_camera = followcam 
351
+            #################
352
+            camspeed1 = .04 #.015
353
+            camspeed2 = .1 #.055
354
+            camrot1 = .02 #.005
355
+            camrot2 = .04 #.02
356
+#            perc = (lUD * 100 * (10 / 80)) *2
357
+#            perc = round(perc,2)
358
+#            print(perc)
359
+#            perc = .025 * perc
360
+#            newUD = (lUD * .1) * 5
361
+#            if lUD > .0005 or lUD < -.0005:
362
+#                camspeed1 = abs(perc)
363
+#                camspeed2 = abs(perc)
364
+            #up
365
+            if lUD < -0.080:
366
+                followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
367
+                cont.activate(followcam.actuators["up"])
368
+                print("fastup")
369
+            else:
370
+                cont.deactivate(followcam.actuators["up"])    
371
+    #            #down    
372
+            if lUD > .080:
373
+                followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
374
+                cont.activate(followcam.actuators["down"])
375
+            else:
376
+                cont.deactivate(followcam.actuators["down"])                    
377
+    #            #left
378
+            if lLR < -0.080:
379
+                followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]                
380
+                cont.activate(followcam.actuators["left"])
381
+            else:
382
+                cont.deactivate(followcam.actuators["left"])                    
383
+    #            #right
384
+            if lLR > 0.080:         
385
+                followcam.actuators["right"].dLoc = [camspeed2, 0, 0]                
386
+                cont.activate(followcam.actuators["right"])
387
+            else:
388
+                cont.deactivate(followcam.actuators["right"])  
389
+            #up
390
+            if rUD < -0.080:
391
+                followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
392
+                cont.activate(followcam.actuators["rotup"])
393
+                #print("uppppppppppppppppppppppppppp")
394
+            else:
395
+                cont.deactivate(followcam.actuators["rotup"])    
396
+    #            #down    
397
+            if rUD > .080:
398
+                followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]                
399
+                cont.activate(followcam.actuators["rotdown"])
400
+            else:
401
+                cont.deactivate(followcam.actuators["rotdown"])                    
402
+    #            #left
403
+            if rLR < -0.080:
404
+                followcam.actuators["rotleft"].dRot = [0, 0, camrot2]                
405
+                cont.activate(followcam.actuators["rotleft"])
406
+            else:
407
+                cont.deactivate(followcam.actuators["rotleft"])                    
408
+    #            #right
409
+            if rLR > 0.080:         
410
+                followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
411
+                cont.activate(followcam.actuators["rotright"])
412
+            else:
413
+                cont.deactivate(followcam.actuators["rotright"]) 
414
+
415
+    #*********************************************                
416
+                
417
+            if lUD > -0.080 and lUD < -0.030:
418
+                followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
419
+                cont.activate(followcam.actuators["up"])
420
+                #print(lUD)
421
+            else:
422
+                cont.deactivate(followcam.actuators["up"])    
423
+    #            #down    
424
+            if lUD < .080 and lUD > .03:
425
+                followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]                
426
+                cont.activate(followcam.actuators["down"])
427
+            else:
428
+                cont.deactivate(followcam.actuators["down"])                    
429
+    #            #left
430
+            if lLR > -0.080 and lLR < -0.030:
431
+                followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]                
432
+                cont.activate(followcam.actuators["left"])
433
+            else:
434
+                cont.deactivate(followcam.actuators["left"])                    
435
+    #            #right
436
+            if lLR < .080 and lLR > .03:       
437
+                followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
438
+                cont.activate(followcam.actuators["right"])
439
+            else:
440
+                cont.deactivate(followcam.actuators["right"])  
441
+            #up
442
+            if rUD > -0.080 and rUD < -0.030:
443
+                followcam.actuators["rotup"].dRot = [camrot1, 0, 0]                
444
+                cont.activate(followcam.actuators["rotup"])
445
+            else:
446
+                cont.deactivate(followcam.actuators["rotup"])    
447
+    #            #down    
448
+            if rUD < .080 and rUD > .03:
449
+                followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]                
450
+                cont.activate(followcam.actuators["rotdown"])
451
+            else:
452
+                cont.deactivate(followcam.actuators["rotdown"])                    
453
+    #            #left
454
+            if rLR > -0.080 and rLR < -0.030:
455
+                followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
456
+                cont.activate(followcam.actuators["rotleft"])
457
+            else:
458
+                cont.deactivate(followcam.actuators["rotleft"])                    
459
+    #            #right
460
+            if rLR < .080 and rLR > .03:         
461
+                followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
462
+                cont.activate(followcam.actuators["rotright"])
463
+            else:
464
+                cont.deactivate(followcam.actuators["rotright"])          
465
+            
466
+            #################
467
+            
468
+        if own['camnum'] == 2 and own['playback']:
469
+            
470
+            scene.active_camera = freecam
471
+            
472
+            #act = freecam.actuators[
473
+            camspeed1 = .015
474
+            camspeed2 = .055
475
+            camrot1 = .005
476
+            camrot2 = .02
477
+            #up
478
+            if lUD < -0.080:
479
+                freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
480
+                cont.activate(freecam.actuators["up"])
481
+                #print("fastup")
482
+            else:
483
+                cont.deactivate(freecam.actuators["up"])    
484
+    #            #down    
485
+            if lUD > .080:
486
+                freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
487
+                cont.activate(freecam.actuators["down"])
488
+            else:
489
+                cont.deactivate(freecam.actuators["down"])                    
490
+    #            #left
491
+            if lLR < -0.080:
492
+                freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]                
493
+                cont.activate(freecam.actuators["left"])
494
+            else:
495
+                cont.deactivate(freecam.actuators["left"])                    
496
+    #            #right
497
+            if lLR > 0.080:         
498
+                freecam.actuators["right"].dLoc = [camspeed2, 0, 0]                
499
+                cont.activate(freecam.actuators["right"])
500
+            else:
501
+                cont.deactivate(freecam.actuators["right"])  
502
+            #up
503
+            if rUD < -0.080:
504
+                freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
505
+                cont.activate(freecam.actuators["rotup"])
506
+            else:
507
+                cont.deactivate(freecam.actuators["rotup"])    
508
+    #            #down    
509
+            if rUD > .080:
510
+                freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]                
511
+                cont.activate(freecam.actuators["rotdown"])
512
+            else:
513
+                cont.deactivate(freecam.actuators["rotdown"])                    
514
+    #            #left
515
+            if rLR < -0.080:
516
+                freecam.actuators["rotleft"].dRot = [0, 0, camrot2]                
517
+                cont.activate(freecam.actuators["rotleft"])
518
+            else:
519
+                cont.deactivate(freecam.actuators["rotleft"])                    
520
+    #            #right
521
+            if rLR > 0.080:         
522
+                freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
523
+                cont.activate(freecam.actuators["rotright"])
524
+            else:
525
+                cont.deactivate(freecam.actuators["rotright"]) 
526
+
527
+    #*********************************************                
528
+                
529
+            if lUD > -0.080 and lUD < -0.030:
530
+                freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
531
+                cont.activate(freecam.actuators["up"])
532
+                #print(lUD)
533
+            else:
534
+                cont.deactivate(freecam.actuators["up"])    
535
+    #            #down    
536
+            if lUD < .080 and lUD > .03:
537
+                freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]                
538
+                cont.activate(freecam.actuators["down"])
539
+            else:
540
+                cont.deactivate(freecam.actuators["down"])                    
541
+    #            #left
542
+            if lLR > -0.080 and lLR < -0.030:
543
+                freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]                
544
+                cont.activate(freecam.actuators["left"])
545
+            else:
546
+                cont.deactivate(freecam.actuators["left"])                    
547
+    #            #right
548
+            if lLR < .080 and lLR > .03:       
549
+                freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
550
+                cont.activate(freecam.actuators["right"])
551
+            else:
552
+                cont.deactivate(freecam.actuators["right"])  
553
+            #up
554
+            if rUD > -0.080 and rUD < -0.030:
555
+                freecam.actuators["rotup"].dRot = [camrot1, 0, 0]                
556
+                cont.activate(freecam.actuators["rotup"])
557
+            else:
558
+                cont.deactivate(freecam.actuators["rotup"])    
559
+    #            #down    
560
+            if rUD < .080 and rUD > .03:
561
+                freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]                
562
+                cont.activate(freecam.actuators["rotdown"])
563
+            else:
564
+                cont.deactivate(freecam.actuators["rotdown"])                    
565
+    #            #left
566
+            if rLR > -0.080 and rLR < -0.030:
567
+                freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
568
+                cont.activate(freecam.actuators["rotleft"])
569
+            else:
570
+                cont.deactivate(freecam.actuators["rotleft"])                    
571
+    #            #right
572
+            if rLR < .080 and rLR > .03:         
573
+                freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
574
+                cont.activate(freecam.actuators["rotright"])
575
+            else:
576
+                cont.deactivate(freecam.actuators["rotright"])        
577
+    ########################################                 
578
+        if own['camnum'] == 0:
579
+            cam = camList["Camera.003"]
580
+            scene.active_camera = cam          
581
+        valueIndex = own['valueIndex']
582
+        n = (valueIndex / recording_cutoff) * 1000
583
+        n = int(round(n))
584
+        #n = 10
585
+        #print("n: ", n, "--", valueIndex, recording_cutoff)
586
+        #dict = logic.globalDict #Get the global dictionary
587
+        dict['playhead'] = n 
588
+          
589
+        own['last_back_but'] = own['back_but']           
590
+        own['back_but'] = back_on
591
+        own['last_a_but'] = own['a_but']           
592
+        own['a_but'] = a_on
593
+        own['last_ltsBut'] = ltsBut
594
+        own['last_rtsBut'] = rtsBut
595
+        own['last_playback'] = own['playback']
596
+        dict['playback'] = own['playback']

+ 172
- 0
scripts/MusicPlayer.py View File

1
+import bge
2
+import os
3
+import aud
4
+import random
5
+import glob
6
+from DList import DoubleList
7
+from collections import OrderedDict
8
+from tinytag import TinyTag
9
+
10
+""" This is the Music Player as a component """
11
+class MusicPlayer(bge.types.KX_PythonComponent):
12
+
13
+    args = OrderedDict([])    
14
+
15
+    def start(self, args):
16
+        # dictionary
17
+        self.dictionary = bge.logic.globalDict
18
+        
19
+        # get mp3 files from the disk and create a list
20
+        self.directory = bge.logic.expandPath('//Music')
21
+        file_name = self.directory + '\\*.mp3'
22
+        file_list =  glob.glob(file_name)
23
+        
24
+        # use the mp3 list to make a playlist of nodes
25
+        self.playlist = DoubleList()
26
+        for name in file_list:
27
+            self.playlist.append(name)
28
+        
29
+        # previously played list of nodes
30
+        self.alreadyPlayed = DoubleList()
31
+        
32
+        # get a random song from the playlist, 
33
+        # remove it from the playlist
34
+        # add it to the alreadyPlayed list
35
+        # NOTICE: currentNode is a reference to a NODE in a list, if you want to play the song inside the node, use .data
36
+        self.currentNode = self.playlist.get(random.randint(0, self.playlist.getLength()))
37
+        self.nowPlaying = self.currentNode.getData()
38
+        self.playlist.remove(self.currentNode)
39
+        self.alreadyPlayed.append(self.nowPlaying)
40
+        print("Now Playing: " + self.nowPlaying)
41
+        self.setTag()
42
+        self.isPlaying = False
43
+
44
+        # create audio devices
45
+        self.device = aud.device()
46
+        self.factory = aud.Factory(self.nowPlaying)
47
+        self.handle = None        
48
+    
49
+    """ Update is called once every frame, and this is where
50
+        any input handling should go
51
+        
52
+        Controller Buttons: 
53
+        Y-Button - Play/Pause
54
+        LB       - Previous Track
55
+        RB       - Next Track
56
+        
57
+        TODO: Keyboard Buttons if these aren't alright
58
+        P        - Play/Pause
59
+        Pad Plus - Next Track
60
+        Pad Minus- Prev Track
61
+    """
62
+    def update(self):
63
+        keyboard = bge.logic.keyboard.events
64
+        up_dict = bge.logic.globalDict
65
+        #print(dictionary)
66
+        pKey = keyboard[bge.events.PKEY]
67
+        pPlus = keyboard[bge.events.PADPLUSKEY]
68
+        pMinus = keyboard[bge.events.PADMINUS]
69
+        lb = up_dict['lBump']
70
+        last_lb = up_dict['last_lBump']
71
+        rb = up_dict['rBump']
72
+        last_rb = up_dict['last_rBump']
73
+        y = up_dict['yBut']
74
+        last_y = up_dict['last_yBut']
75
+        JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
76
+        
77
+
78
+        #Run player on startup
79
+        if up_dict['music_start'] == True:
80
+            if self.isPlaying:
81
+                self.stopMusic()
82
+            else:
83
+                self.playMusic()                 
84
+            up_dict['music_start'] = False               
85
+
86
+        # Music controls only during pause/replay
87
+        if (up_dict['npause'] == True or up_dict['playback'] == True) or up_dict['music_start'] == True:
88
+            #stop/play
89
+            if (y == False and last_y == True) or pKey == JUST_ACTIVATED:
90
+                if self.isPlaying:
91
+                    self.stopMusic()
92
+                    up_dict['music_player'] = 0
93
+                else:
94
+                    self.playMusic()
95
+                    up_dict['music_player'] = 1
96
+            # Prev/Next
97
+            if self.isPlaying and self.handle.status:
98
+                if pMinus == JUST_ACTIVATED or (lb == False and last_lb == True):
99
+                    self.prevSong()
100
+                
101
+                if pPlus == JUST_ACTIVATED or (rb == False and last_rb == True):
102
+                    self.nextSong()
103
+        # if song ends, play next song
104
+        if self.isPlaying and not self.handle.status:
105
+            self.nextSong()
106
+
107
+    """ get info about song using TinyTag, then print to console """
108
+    def setTag(self):                
109
+        self.currTrackPath = os.path.join(self.directory, self.nowPlaying)
110
+        tag = TinyTag.get(self.currTrackPath)
111
+        self.currArtist = tag.artist
112
+        self.currTrackTitle = tag.title
113
+        self.dictionary['mu_artist'] = self.currArtist
114
+        self.dictionary['mu_title'] = self.currTrackTitle
115
+                
116
+        print('Artist: %s' % self.currArtist, 
117
+                ' Track: %s' % self.currTrackTitle)
118
+
119
+    def playMusic(self):
120
+        print('Play Music')
121
+        self.setTag()
122
+        self.handle = self.device.play(self.factory)
123
+        self.isPlaying = True
124
+        
125
+    def stopMusic(self):
126
+        print('Stop Music')
127
+        self.handle.stop()
128
+        self.isPlaying = False
129
+        
130
+    def nextSong(self):
131
+        print('Next Song')
132
+        # stop the current song
133
+        self.handle.stop()
134
+        
135
+        # get a song from the playlist
136
+        self.currentNode = self.playlist.get(random.randint(0, self.playlist.getLength()))
137
+        self.nowPlaying = self.currentNode.getData()
138
+        self.playlist.remove(self.currentNode)
139
+                
140
+        # add the song to the already played list
141
+        self.alreadyPlayed.append(self.nowPlaying)  
142
+        
143
+        # start the song
144
+        self.factory = aud.Factory(self.nowPlaying)
145
+        self.handle = self.device.play(self.factory)
146
+        self.setTag()
147
+        
148
+        # If playlist is empty, re-fill it
149
+        if self.playlist.getLength() == 0:
150
+            file_name = self.directory + '\\*.mp3'
151
+            file_list =  glob.glob(file_name)
152
+            for name in file_list:
153
+                self.playlist.append(name)
154
+        
155
+    """ Note on first call of this method, the current node will be equal to the tail of the already played list, 
156
+        however, it will be a node from a different list. We need to set current node equal to the tail node
157
+        of the already played list so that we can iterate through that list, instead of the other list """
158
+    def prevSong(self):
159
+        print('Prev Song')
160
+        # stop the current song
161
+        self.handle.stop()        
162
+        
163
+        if self.currentNode.getData() == self.alreadyPlayed.getTail().getData():
164
+            self.currentNode = self.alreadyPlayed.getTail()
165
+            
166
+        self.currentNode = self.currentNode.getPrev()
167
+        self.nowPlaying = self.currentNode.getData()
168
+        
169
+        # start the song
170
+        self.factory = aud.Factory(self.nowPlaying)
171
+        self.handle = self.device.play(self.factory)
172
+        self.setTag()

+ 2
- 0
scripts/README.md View File

1
+# shuvit
2
+Open source skateboarding game made with UPBGE / Blender.

+ 716
- 0
scripts/Record.py View File

1
+#record
2
+from bge import logic
3
+from mathutils import Vector
4
+from SortData import *
5
+
6
+cont = logic.getCurrentController()
7
+own = cont.owner
8
+scene = logic.getCurrentScene()
9
+cube = scene.objects["control_cube.002"]
10
+#obj = scene.objects["control_cube.002"]
11
+#sound_empty = scene.objects['replay_sound_empty']
12
+path = logic.expandPath(own["filePath"])
13
+
14
+PAF = 0
15
+DAF = 0
16
+
17
+deck = scene.objects["deck"]
18
+trucks = scene.objects["trucks"]
19
+
20
+throw_deck_empty = scene.objects["throw_deck_empty"]
21
+wheel1 = scene.objects["rollen.000"]
22
+wheel2 = scene.objects["rollen.001"]
23
+wheel3 = scene.objects["rollen.002"]
24
+wheel4 = scene.objects["rollen.003"]
25
+
26
+try:
27
+    throw_deck = scene.objects['throw_deck']
28
+except:
29
+    throw_deck = None    
30
+
31
+deckact = deck.actuators["Visibility"]
32
+trucksact = trucks.actuators["Visibility"]
33
+wheel1act = wheel1.actuators["Visibility"]
34
+wheel2act = wheel2.actuators["Visibility"]
35
+wheel3act = wheel3.actuators["Visibility"]
36
+wheel4act = wheel4.actuators["Visibility"]
37
+
38
+class getData:
39
+
40
+
41
+
42
+    def savePosition(obj, cut):
43
+        position = [Vector(obj.worldPosition)[0],
44
+            Vector(obj.worldPosition)[1],
45
+            Vector(obj.worldPosition)[2]]
46
+        position = str(position).strip("[]")
47
+        position = position.replace(", ",",")
48
+        writeData.addPosition(obj, position, cut)
49
+     
50
+    def saveOrientation(obj, cut): 
51
+        orientation = [Vector(obj.localOrientation.to_euler())[0],
52
+            Vector(obj.localOrientation.to_euler())[1],
53
+            Vector(obj.localOrientation.to_euler())[2]]
54
+        orientation = str(orientation).strip("[]")
55
+        orientation = orientation.replace(", ",",")     
56
+        writeData.addOrientation(obj, orientation, cut)
57
+                    
58
+    def saveScale(obj, cut):  
59
+        scale = [Vector(obj.localScale)[0],
60
+            Vector(obj.localScale)[1],
61
+            Vector(obj.localScale)[2]]
62
+        scale = str(scale).strip("[]")
63
+        scale = scale.replace(", ",",")
64
+        writeData.addScale(obj, scale, cut)
65
+    def saveColor(obj, cut):
66
+        color = [Vector(obj.color)[0],
67
+            Vector(obj.color)[1],
68
+            Vector(obj.color)[2],
69
+            Vector(obj.color)[3]]
70
+        color = str(color).strip("[]")
71
+        color = color.replace(", ",",")
72
+        writeData.addColor(obj, color, cut)
73
+    def saveState(obj, cut):
74
+        
75
+        state = str(obj.state)
76
+        writeData.addState(obj, state, cut)
77
+        
78
+    def saveVisibility(obj, cut):
79
+        visible = obj.visible
80
+        if visible:
81
+            visible = 1
82
+        else:
83
+            visible = 0   
84
+        writeData.addVisibility(obj, str(visible), cut)
85
+    
86
+    def saveSkaterAnim(obj, cut):
87
+        import bge
88
+        scene = bge.logic.getCurrentScene()
89
+        skater = scene.objects["Char4"]
90
+        deck = scene.objects["deck"]
91
+        trucks = scene.objects["trucks"]
92
+        playing_layer = 0
93
+        for x in range(7):
94
+            l1 = skater.isPlayingAction(x)
95
+            if l1 == True:
96
+                playing_layer = x
97
+                #print(x)
98
+        playing_action = skater.getActionName(playing_layer)
99
+        playing_action_frame = skater.getActionFrame(playing_layer)
100
+        PAF = playing_action_frame
101
+        own['PAF'] = PAF
102
+       #print(playing_action, playing_action_frame)        
103
+        writeData.addSkaterAnim(obj, str(playing_action), cut)
104
+        
105
+    def saveSkaterAnimF(obj, cut):
106
+        PAF = own['PAF']
107
+        writeData.addSkaterAnimF(obj, str(PAF), cut)   
108
+        
109
+    def saveDeckAnim(obj, cut):
110
+        import bge
111
+        scene = bge.logic.getCurrentScene()
112
+        skater = scene.objects["Char4"]
113
+        deck = scene.objects["deck"]
114
+        trucks = scene.objects["trucks"]
115
+        wheel1 = scene.objects["rollen.000"]
116
+        wheel2 = scene.objects["rollen.001"]
117
+        wheel3 = scene.objects["rollen.002"]
118
+        wheel4 = scene.objects["rollen.003"]        
119
+        playing_layer = 0
120
+        for x in range(7):
121
+            l1 = deck.isPlayingAction(x)
122
+            if l1 == True:
123
+                playing_layer = x
124
+                #print(x)
125
+        playing_action = deck.getActionName(playing_layer)
126
+        playing_action_frame = deck.getActionFrame(playing_layer)
127
+        DAF = playing_action_frame
128
+        own['DAF'] = DAF
129
+       #print(playing_action, playing_action_frame)        
130
+        writeData.addDeckAnim(obj, str(playing_action), cut)
131
+        
132
+    def saveDeckAnimF(obj, cut):
133
+        DAF = own['DAF']
134
+        writeData.addDeckAnimF(obj, str(DAF), cut)
135
+
136
+    def saveSrollVol(obj, cut):
137
+        num = cube['sroll_vol']
138
+        writeData.addSrollVol(obj, str(num), cut) 
139
+    def saveSrollPitch(obj, cut):
140
+        num = cube['sroll_pitch']
141
+        writeData.addSrollPitch(obj, str(num), cut) 
142
+    
143
+    def saveSgrind_cementVol(obj, cut):
144
+        num = cube['grindcement_vol']
145
+        writeData.addSgrind_cementVol(obj, str(num), cut) 
146
+    def saveSgrind_cementPitch(obj, cut):
147
+        num = cube['grindcement_pitch']
148
+        writeData.addSgrind_cementPitch(obj, str(num), cut) 
149
+    def saveSgrind_railVol(obj, cut):
150
+        num = cube['grindrail_vol']
151
+        writeData.addSgrind_railVol(obj, str(num), cut) 
152
+    def saveSgrind_railPitch(obj, cut):
153
+        num = cube['grindrail_pitch']
154
+        writeData.addSgrind_railPitch(obj, str(num), cut)
155
+    def saveSpopsound(obj, cut):
156
+        num = cube['pop_sound']
157
+        writeData.addSpopsound(obj, str(num), cut) 
158
+    def saveSlandsound(obj, cut):
159
+        num = cube['land_sound']
160
+        writeData.addSlandsound(obj, str(num), cut) 
161
+    def saveSdeckvis(obj, cut):
162
+        num = cube['deckvis']
163
+        writeData.addSdeckvis(obj, str(num), cut)  
164
+        
165
+    def savetdPosition(obj, cut):
166
+        try:
167
+            obj = scene.objects['throw_deck']
168
+        except:
169
+            pass    
170
+        position = [Vector(obj.worldPosition)[0],
171
+            Vector(obj.worldPosition)[1],
172
+            Vector(obj.worldPosition)[2]]
173
+        position = str(position).strip("[]")
174
+        position = position.replace(", ",",")
175
+        writeData.addtdPosition(obj, position, cut)
176
+     
177
+    def savetdOrientation(obj, cut): 
178
+        try:
179
+            obj = scene.objects['throw_deck']
180
+        except:
181
+            pass
182
+        orientation = [Vector(obj.localOrientation.to_euler())[0],
183
+            Vector(obj.localOrientation.to_euler())[1],
184
+            Vector(obj.localOrientation.to_euler())[2]]
185
+        orientation = str(orientation).strip("[]")
186
+        orientation = orientation.replace(", ",",")     
187
+        writeData.addtdOrientation(obj, orientation, cut)
188
+    def saveSrevertsound(obj, cut):
189
+        num = cube['revert_sound']
190
+        writeData.addSrevertsound(obj, str(num), cut)                                                                               
191
+              
192
+def loadData():
193
+    
194
+    #Function for loading the data from
195
+    #the disk and setting it.
196
+    
197
+    objIndex = own["objIndex"]
198
+    own["valueIndex"] = objIndex + 1
199
+    valueIndex = own["valueIndex"]
200
+    playbackSpeed = own["playbackSpeed"]
201
+    loadedPosition = own["loadedPosition"]
202
+    loadedOrientation = own["loadedOrientation"]
203
+    loadedScale = own["loadedScale"]
204
+    loadedColor = own["loadedColor"]
205
+    loadedVisibility = own["loadedVisibility"]
206
+    loadedSkaterAnim = own["loadedSkaterAnim"]
207
+    loadedSkaterAnimf = own["loadedSkaterAnimF"]
208
+    loadedDeckAnim = own["loadedDeckAnim"]
209
+    loadedDeckAnimf = own["loadedDeckAnimF"]
210
+    loadedSrollVol = own["loadedSrollVol"]
211
+    loadedSrollPitch = own["loadedSrollPitch"]
212
+    loadedSgrind_cementlVol = own["loadedSgrind_cementVol"]
213
+    loadedSgrind_cementPitch = own["loadedSgrind_cementPitch"]
214
+    loadedSgrind_railVol = own["loadedSgrind_railVol"]
215
+    loadedSgrind_railPitch = own["loadedSgrind_railPitch"] 
216
+    loadedSpopsound = own["loadedSpopsound"]            
217
+    loadedSlandsound = own["loadedSlandsound"] 
218
+    loadedSdeckvis = own["loadedSdeckvis"]  
219
+    loadedtdPosition = own["loadedtdPosition"]
220
+    loadedtdOrientation = own["loadedtdOrientation"]      
221
+    loadedSrevertsound = own["loadedSrevertsound"] 
222
+    
223
+    skater = scene.objects["Char4"]
224
+    deck = scene.objects["deck"]
225
+    trucks = scene.objects["trucks"]
226
+    
227
+    num = 1
228
+    obj = scene.objects['control_cube.002']
229
+    if num == 1:    
230
+    #for obj in scene.objects:        
231
+        if not "recorder" in obj:
232
+            obj.state = 100
233
+            obj.suspendDynamics()
234
+                     
235
+    readData.loadAll()    #Load the file!!!
236
+    
237
+    #-----Position-----#
238
+    own["lengthPos"] = readData.getLengthPos()
239
+    lengthPos = own["lengthPos"] 
240
+    
241
+    if lengthPos:
242
+        
243
+        if objIndex > lengthPos-1:
244
+            own["objIndex"] = 0
245
+        if objIndex < 0:
246
+            own["objIndex"] = lengthPos-2
247
+
248
+        name, position = readData.returnPosition(objIndex, valueIndex)
249
+        
250
+        if name in scene.objects:
251
+            try:
252
+                scene.objects[name].worldPosition = position
253
+                scene.objects['replay_sound_empty'].worldPosition = position
254
+                #print("replay_sound_empty changing position")
255
+            except:
256
+                pass
257
+    #-----Orientation-----#
258
+    own["lengthOri"] = readData.getLengthOri()   
259
+    lengthOri = own["lengthOri"]
260
+    
261
+    #if lengthPos:
262
+    if lengthOri:
263
+  
264
+        if valueIndex > lengthOri-1:
265
+            own["valueIndex"] = 0
266
+        if objIndex < 0:
267
+            own["objIndex"] = lengthOri-2
268
+
269
+        name, orientation = readData.returnOrientation(objIndex, valueIndex)
270
+        
271
+        if name in scene.objects:
272
+            oXYZ = scene.objects[name].localOrientation.to_euler()
273
+
274
+            oXYZ[0] = float(orientation[0])
275
+            oXYZ[1] = float(orientation[1])
276
+            oXYZ[2] = float(orientation[2])
277
+            
278
+            try:
279
+                scene.objects[name].localOrientation = oXYZ.to_matrix()
280
+            except:
281
+                pass
282
+    #-----Scale-----#
283
+    own["lengthSca"] = readData.getLengthSca()
284
+    lengthSca = own["lengthSca"]
285
+    
286
+    if lengthSca:
287
+    
288
+        if valueIndex > lengthSca-1:
289
+            own["valueIndex"] = 0
290
+        if objIndex < 0:
291
+            own["objIndex"] = lengthSca-2
292
+       
293
+        name, scale = readData.returnScale(objIndex, valueIndex)
294
+        
295
+        if name in scene.objects:
296
+            try:
297
+                scene.objects[name].localScale = scale
298
+            except:
299
+                pass
300
+    #-----Color-----#
301
+    own["lengthCol"] = readData.getLengthCol()   
302
+    lengthCol = own["lengthCol"]
303
+    
304
+    if lengthCol:
305
+
306
+        if valueIndex > lengthCol-1:
307
+            own["valueIndex"] = 0
308
+        if objIndex < 0:
309
+            own["objIndex"] = lengthCol-2
310
+
311
+        name, color = readData.returnColor(objIndex, valueIndex)
312
+        
313
+        if name in scene.objects:
314
+            try:
315
+                scene.objects[name].color = color
316
+            except:
317
+                pass
318
+    #-----Visibility-----#
319
+    own["lengthVis"] = readData.getLengthVis()
320
+    lengthVis = own["lengthVis"]
321
+    
322
+    if lengthVis:
323
+
324
+        if valueIndex > lengthVis-1:
325
+            own["valueIndex"] = 0
326
+        if objIndex < 0:
327
+            own["objIndex"] = lengthVis-2
328
+
329
+        name, visible = readData.returnVisibility(objIndex, valueIndex)
330
+        
331
+        if name in scene.objects:
332
+            try:
333
+                scene.objects[name].visible = int(visible)
334
+            except:
335
+                pass
336
+    #-----Skater Animation Name-----#
337
+    own["lengthSkaterAnim"] = readData.getLengthSkaterAnim()
338
+    lengthSkaterAnim = own["lengthSkaterAnim"]
339
+    #print("lengthskateranim", lengthSkaterAnim)
340
+    if lengthSkaterAnim:
341
+
342
+        if valueIndex > lengthSkaterAnim-1:
343
+            own["valueIndex"] = 0
344
+        if objIndex < 0:
345
+            own["objIndex"] = lengthSkaterAnim-2
346
+
347
+        name, skateranim = readData.returnSkaterAnim(objIndex, valueIndex)
348
+        name, PAF = readData.returnSkaterAnimF(objIndex, valueIndex)
349
+        #print(PAF)
350
+        PAF = float(PAF)
351
+        if name in scene.objects:
352
+            #print("name in")
353
+            try:
354
+                skater.stopAction(0)
355
+                skater.stopAction(1)
356
+                skater.stopAction(2)
357
+                skater.stopAction(3)
358
+                skater.stopAction(9999)
359
+                if skater != '':
360
+                    skater.playAction(skateranim, PAF,PAF, layer=9999, play_mode=1, speed=1)
361
+                #print("Playing: ", skateranim, PAF)
362
+            except:
363
+                print("something is wrong")
364
+                #pass  
365
+                
366
+                
367
+    #-----Deck Animation Name-----#
368
+    own["lengthDeckAnim"] = readData.getLengthDeckAnim()
369
+    lengthDeckAnim = own["lengthDeckAnim"]
370
+    #print("lengthDeckanim", lengthDeckAnim)
371
+    if lengthDeckAnim:
372
+
373
+        if valueIndex > lengthDeckAnim-1:
374
+            own["valueIndex"] = 0
375
+        if objIndex < 0:
376
+            own["objIndex"] = lengthDeckAnim-2
377
+
378
+        name, deckanim = readData.returnDeckAnim(objIndex, valueIndex)
379
+        name, DAF = readData.returnDeckAnimF(objIndex, valueIndex)
380
+        #print(DAF)
381
+        DAF = float(DAF)
382
+        if name in scene.objects:
383
+            #print("name in")
384
+            try:
385
+                deck.stopAction(0)
386
+                deck.stopAction(1)
387
+                deck.stopAction(2)
388
+                deck.stopAction(3)
389
+                deck.stopAction(9999)
390
+                #print(deckanim)
391
+                if deckanim != '':
392
+                    turnList = ['a_reg_right', 'a_reg_left', 'a_fak_right', 'a_fak_left']
393
+                    #print(deckanim)
394
+                    if deckanim not in turnList:
395
+                        deck.playAction(deckanim, DAF,DAF, layer=9999, play_mode=1, speed=1)
396
+                        trucks.playAction(deckanim, DAF,DAF, layer=9999, play_mode=1, speed=1)
397
+                    else:
398
+                        print('play a_reg')  
399
+                        deck.playAction(deckanim, DAF,DAF, layer=9999, play_mode=1, speed=1)
400
+                        trucks.playAction('a_reg', DAF,DAF, layer=9999, play_mode=1, speed=1)                          
401
+                #print("Playing: ", deckanim, PAF)
402
+            except:
403
+                print("deck something is wrong")
404
+                #pass  
405
+
406
+#
407
+    #-----sroll-----#
408
+    own["lengthSrollVol"] = readData.getLengthSrollVol()
409
+    lengthSrollVol = own["lengthSrollVol"]
410
+    if lengthSrollVol:
411
+        if valueIndex > lengthSrollVol-1:
412
+            own["valueIndex"] = 0
413
+        if objIndex < 0:
414
+            own["objIndex"] = lengthSrollVol-2
415
+        name, srollVol = readData.returnSrollVol(objIndex, valueIndex)
416
+        name, srollPitch = readData.returnSrollPitch(objIndex, valueIndex)    
417
+        if name in scene.objects:
418
+            try:
419
+                cube = scene.objects["control_cube.002"]
420
+                srollVol = round(srollVol, 2)
421
+                act = cube.actuators["sroll"]
422
+                if srollVol < .12:
423
+                    act.volume = srollVol
424
+                    act.pitch = srollPitch
425
+                act.startSound()
426
+            except:
427
+                pass
428
+###            
429
+#
430
+    #-----grind cement-----#
431
+    own["lengthSgrind_cementVol"] = readData.getLengthSgrind_cementVol()
432
+    lengthSgrind_cementVol = own["lengthSgrind_cementVol"]
433
+    if lengthSgrind_cementVol:
434
+        if valueIndex > lengthSgrind_cementVol-1:
435
+            own["valueIndex"] = 0
436
+        if objIndex < 0:
437
+            own["objIndex"] = lengthSgrind_cementVol-2
438
+        name, sgrind_cementVol = readData.returnSgrind_cementVol(objIndex, valueIndex)
439
+        name, sgrind_cementPitch = readData.returnSgrind_cementPitch(objIndex, valueIndex)    
440
+        if name in scene.objects:
441
+            try:
442
+                cube = scene.objects["control_cube.002"]
443
+                sgrind_cementVol = round(sgrind_cementVol, 2)
444
+                act = cube.actuators["grind_cement"]
445
+                if sgrind_cementVol < .2:
446
+                    act.volume = sgrind_cementVol
447
+                    act.pitch = sgrind_cementPitch
448
+                act.startSound()
449
+                
450
+            except:
451
+                pass
452
+###    
453
+#
454
+    #-----grind rail-----#
455
+    own["lengthSgrind_railVol"] = readData.getLengthSgrind_railVol()
456
+    lengthSgrind_railVol = own["lengthSgrind_railVol"]
457
+    if lengthSgrind_railVol:
458
+        if valueIndex > lengthSgrind_railVol-1:
459
+            own["valueIndex"] = 0
460
+        if objIndex < 0:
461
+            own["objIndex"] = lengthSgrind_railVol-2
462
+        name, sgrind_railVol = readData.returnSgrind_railVol(objIndex, valueIndex)
463
+        name, sgrind_railPitch = readData.returnSgrind_railPitch(objIndex, valueIndex)    
464
+        if name in scene.objects:
465
+            try:
466
+                cube = scene.objects["control_cube.002"]
467
+                sgrind_railVol = round(sgrind_railVol, 2)
468
+                act = cube.actuators["grind_rail"]
469
+                if sgrind_railVol < .2:
470
+                    act.volume = sgrind_railVol
471
+                    act.pitch = sgrind_railPitch
472
+                act.startSound()
473
+                #print("grindsound = ", sgrind_railVol, sgrind_railPitch)
474
+            except:
475
+                pass
476
+###  
477
+#
478
+    #-----pop sound-----#
479
+    own["lengthSpopsound"] = readData.getLengthSpopsound()
480
+    lengthSpopsound = own["lengthSpopsound"]
481
+    if lengthSpopsound:
482
+        if valueIndex > lengthSpopsound-1:
483
+            own["valueIndex"] = 0
484
+        if objIndex < 0:
485
+            own["objIndex"] = lengthSpopsound-2
486
+        name, spopsound = readData.returnSpopsound(objIndex, valueIndex)   
487
+        if name in scene.objects:
488
+            #act = sound_empty.actuators["pop"]
489
+            try:
490
+                #cube = scene.objects[sound_empty]
491
+                spopsound = round(spopsound, 2)
492
+                act = cube.actuators["pop"]
493
+                #act = sound_empty.actuators["pop"]
494
+                if spopsound == 1:
495
+                    #act.volume_maximum = .7
496
+                    #act.is3D = True
497
+                    #act.distance_reference = 10.0
498
+                    #act.distance_maximum = 50.0
499
+                    act.volume = .6
500
+                    act.startSound()
501
+                #print("grindsound = ", spopsound, sgrind_railPitch)
502
+            except:
503
+                print("sound passed")
504
+                pass
505
+###
506
+#
507
+    #-----land sound-----#
508
+    own["lengthSlandsound"] = readData.getLengthSlandsound()
509
+    lengthSlandsound = own["lengthSlandsound"]
510
+    if lengthSlandsound:
511
+        if valueIndex > lengthSlandsound-1:
512
+            own["valueIndex"] = 0
513
+        if objIndex < 0:
514
+            own["objIndex"] = lengthSlandsound-2
515
+        name, slandsound = readData.returnSlandsound(objIndex, valueIndex)   
516
+        if name in scene.objects:
517
+            try:
518
+                cube = scene.objects["control_cube.002"]
519
+                slandsound = round(slandsound, 2)
520
+                act = cube.actuators["land"]
521
+                if slandsound == 1:
522
+                    act.volume = .6
523
+                    act.startSound()
524
+                #print("grindsound = ", slandsound, sgrind_railPitch)
525
+            except:
526
+                pass
527
+###  
528
+###
529
+#
530
+    #-----land sound-----#
531
+    own["lengthSdeckvis"] = readData.getLengthSdeckvis()
532
+    lengthSdeckvis = own["lengthSdeckvis"]
533
+    if lengthSdeckvis:
534
+        if valueIndex > lengthSdeckvis-1:
535
+            own["valueIndex"] = 0
536
+        if objIndex < 0:
537
+            own["objIndex"] = lengthSdeckvis-2
538
+        name, sdeckvis = readData.returnSdeckvis(objIndex, valueIndex)   
539
+        
540
+        
541
+        if name in scene.objects:
542
+            try:
543
+                cube = scene.objects["control_cube.002"]
544
+                if sdeckvis == 1:
545
+                    #print('setting deck visible')
546
+                    deckact.visibility = True
547
+                    trucksact.visibility = True
548
+                    wheel1act.visibility = True
549
+                    wheel2act.visibility = True
550
+                    wheel3act.visibility = True
551
+                    wheel4act.visibility = True   
552
+                    cont.activate(deck.actuators['Visibility'])
553
+                    cont.activate(trucks.actuators['Visibility'])
554
+                    cont.activate(wheel1.actuators['Visibility'])
555
+                    cont.activate(wheel2.actuators['Visibility'])
556
+                    cont.activate(wheel3.actuators['Visibility'])
557
+                    cont.activate(wheel4.actuators['Visibility'])  
558
+                    for n in scene.objects:
559
+                        if 'throw_deck' in n.name and 'empty' not in n.name:
560
+                            n.endObject() 
561
+#                    if 'throw_deck' in scene.objects:
562
+                            #print('ending td', n)
563
+                            cont.activate(throw_deck.actuators['end_throw_deck'])                   
564
+                     
565
+                    #throwdeck.visibility = False                               
566
+                else:
567
+                    #print('setting deck invisible')
568
+                    deckact.visibility = False
569
+                    trucksact.visibility = False
570
+                    wheel1act.visibility = False
571
+                    wheel2act.visibility = False
572
+                    wheel3act.visibility = False
573
+                    wheel4act.visibility = False   
574
+                    cont.activate(deck.actuators['Visibility'])
575
+                    cont.activate(trucks.actuators['Visibility'])
576
+                    cont.activate(wheel1.actuators['Visibility'])
577
+                    cont.activate(wheel2.actuators['Visibility'])
578
+                    cont.activate(wheel3.actuators['Visibility'])
579
+                    cont.activate(wheel4.actuators['Visibility'])  
580
+                    #if throw_deck == None:
581
+                    if 'throw_deck' not in scene.objects:
582
+                        #print('no throwdeck')
583
+                        #cont.deactivate(throw_deck.actuators['end_throw_deck']) 
584
+                        #throw_deck_empty.wordPosition.z = throw_deck_empty.wordPosition.z + 1
585
+                        cont.activate(throw_deck_empty.actuators['throw_dec_act']) 
586
+                        #scene.addObject('throw_deck')
587
+                    #throwdeck.visibility = True
588
+                    throw_deck.suspendDynamics()
589
+
590
+            except:
591
+                pass
592
+##    
593
+    #-----Position-----#
594
+    own["lengthtdPos"] = readData.getLengthtdPos()
595
+    lengthPos = own["lengthtdPos"] 
596
+    
597
+    if lengthPos:
598
+        
599
+        if objIndex > lengthPos-1:
600
+            own["objIndex"] = 0
601
+        if objIndex < 0:
602
+            own["objIndex"] = lengthPos-2
603
+
604
+        name, position = readData.returntdPosition(objIndex, valueIndex)
605
+        name = 'throw_deck'
606
+        if name in scene.objects:
607
+            try:
608
+                scene.objects[name].worldPosition = position
609
+                #print('recording tdPos', position)
610
+            except:
611
+                pass
612
+    #-----Orientation-----#
613
+    own["lengthtdOri"] = readData.getLengthtdOri()   
614
+    lengthOri = own["lengthtdOri"]
615
+    
616
+    #if lengthPos:
617
+    if lengthOri:
618
+  
619
+        if valueIndex > lengthOri-1:
620
+            own["valueIndex"] = 0
621
+        if objIndex < 0:
622
+            own["objIndex"] = lengthOri-2
623
+
624
+        name, orientation = readData.returntdOrientation(objIndex, valueIndex)
625
+        name = 'throw_deck'
626
+        if name in scene.objects:
627
+            
628
+            oXYZ = scene.objects[name].localOrientation.to_euler()
629
+
630
+            oXYZ[0] = float(orientation[0])
631
+            oXYZ[1] = float(orientation[1])
632
+            oXYZ[2] = float(orientation[2])
633
+            
634
+            try:
635
+                #print('recording tdOri')
636
+                scene.objects[name].localOrientation = oXYZ.to_matrix()
637
+            except:
638
+                pass
639
+
640
+#
641
+    #-----revert sound-----#
642
+    own["lengthSrevertsound"] = readData.getLengthSrevertsound()
643
+    lengthSrevertsound = own["lengthSrevertsound"]
644
+    if lengthSrevertsound:
645
+        if valueIndex > lengthSrevertsound-1:
646
+            own["valueIndex"] = 0
647
+        if objIndex < 0:
648
+            own["objIndex"] = lengthSrevertsound-2
649
+        name, srevertsound = readData.returnSrevertsound(objIndex, valueIndex)   
650
+        if name in scene.objects:
651
+            try:
652
+                #cube = scene.objects[sound_empty]
653
+                srevertsound = round(srevertsound, 2)
654
+                act = cube.actuators["revertSound"]
655
+                if srevertsound == 1:
656
+                    act.startSound()
657
+                #print("grindsound = ", spopsound, sgrind_railPitch)
658
+            except:
659
+                print("sound passed")
660
+                pass
661
+
662
+                                            
663
+                       
664
+def main(recording_cutoff, cc):
665
+    num = 1
666
+    obj = scene.objects["control_cube.002"]
667
+    if num == 1:
668
+        
669
+    #for obj in scene.objects:
670
+        if "record_position" in obj:
671
+            getData.savePosition(obj, recording_cutoff)
672
+        if "record_orientation" in obj:
673
+            getData.saveOrientation(obj, recording_cutoff)
674
+        if "record_scale" in obj:
675
+            getData.saveScale(obj, recording_cutoff)
676
+        if "record_color" in obj:
677
+            getData.saveColor(obj, recording_cutoff)
678
+        if "record_state" in obj:
679
+            getData.saveState(obj, recording_cutoff)
680
+        if "record_visibility" in obj:
681
+            getData.saveVisibility(obj, recording_cutoff)
682
+        if "record_skateranim" in obj:
683
+            getData.saveSkaterAnim(obj, recording_cutoff)
684
+        if "record_skateranimf" in obj:
685
+            getData.saveSkaterAnimF(obj, recording_cutoff) 
686
+        if "record_deckanim" in obj:
687
+            getData.saveDeckAnim(obj, recording_cutoff)
688
+        if "record_deckanimf" in obj:
689
+            getData.saveDeckAnimF(obj, recording_cutoff)    
690
+        #if "record_sroll_vol" in obj:
691
+        getData.saveSrollVol(obj, recording_cutoff)
692
+        #if "record_sroll_pitch" in obj:
693
+        getData.saveSrollPitch(obj, recording_cutoff)
694
+        getData.saveSgrind_cementVol(obj, recording_cutoff)
695
+        getData.saveSgrind_cementPitch(obj, recording_cutoff)
696
+        getData.saveSgrind_railVol(obj, recording_cutoff)
697
+        getData.saveSgrind_railPitch(obj, recording_cutoff)
698
+        getData.saveSpopsound(obj, recording_cutoff)            
699
+        getData.saveSlandsound(obj, recording_cutoff) 
700
+        getData.saveSdeckvis(obj, recording_cutoff) 
701
+        getData.savetdPosition(obj, recording_cutoff)
702
+        getData.savetdOrientation(obj, recording_cutoff)
703
+        getData.saveSrevertsound(obj, recording_cutoff)                                       
704
+            
705
+         
706
+def breakOut():
707
+    num = 1
708
+    obj = scene.objects["control_cube.002"]
709
+    if num == 1:
710
+    #for obj in scene.objects:
711
+        obj.restoreDynamics()
712
+        try:
713
+            name, state = readData.returnState(own["objIndex"], own["valueIndex"])
714
+            obj.state = state
715
+        except:
716
+            pass

+ 96
- 0
scripts/Settings.py View File

1
+import bge
2
+import GameLogic
3
+import configobj
4
+from configobj import ConfigObj
5
+
6
+mainDir = GameLogic.expandPath("//")
7
+
8
+fileName = mainDir + "config.ini"
9
+
10
+config = ConfigObj(fileName, interpolation=True)
11
+dict = bge.logic.globalDict
12
+
13
+print('###############start game##########')
14
+dict['music_player'] = 1
15
+
16
+def to_dict(section, key):
17
+    dict = bge.logic.globalDict
18
+    value = config[key]
19
+    if isinstance(value, str):
20
+        if value.isdigit():
21
+            value = int(value)
22
+        else:
23
+            try:
24
+                value = float(value)
25
+            except:
26
+                pass
27
+    dict[key] = value  
28
+
29
+def readSettings():
30
+    config.walk(to_dict)     
31
+
32
+def from_dict(section, key):
33
+    dict = bge.logic.globalDict
34
+    config[key] = dict[key]
35
+
36
+def writeSettings():
37
+    config.walk(from_dict)  
38
+    config.write()    
39
+          
40
+def setres():
41
+    import GameLogic
42
+    import bge
43
+    scenes = bge.logic.getSceneList()
44
+    main_scene = [scene for scene in scenes if scene.name=="main"][0]
45
+    own = main_scene.objects['Empty']
46
+    cont = GameLogic.getCurrentController()
47
+    own2 = cont.owner
48
+    dict = bge.logic.globalDict 
49
+    resx = int(dict["resx"])
50
+    resy = int(dict["resy"])
51
+    fullscreen = bge.render.getFullScreen()
52
+    print("fullscreen = ", fullscreen)
53
+    if fullscreen != True:
54
+        if dict['fullscreen_on'] == 1:
55
+            bge.render.setFullScreen(True)
56
+    if fullscreen == True:
57
+        if dict['fullscreen_on'] == 0:
58
+            bge.render.setFullScreen(False) 
59
+            
60
+    bge.render.setWindowSize(resx, resy)         
61
+    print("resolution = ", resx, resy)       
62
+        
63
+def loadlevel():
64
+    import GameLogic
65
+    import bge
66
+    scenes = bge.logic.getSceneList()
67
+    main_scene = [scene for scene in scenes if scene.name=="main"][0]
68
+    own = main_scene.objects['Empty']
69
+    cont = GameLogic.getCurrentController()
70
+    own2 = cont.owner
71
+
72
+    dict = bge.logic.globalDict #Get the global dictionary
73
+    
74
+    if own["framerate"] == 1:    
75
+        bge.render.showFramerate(1)
76
+    if own["profile"] ==1:    
77
+        bge.render.showProfile(1)   
78
+    act = own2.actuators["level"]
79
+    dict = bge.logic.globalDict
80
+    level = dict['level']
81
+    print('loading level', level)
82
+    act.scene = level 
83
+    cont.activate(own2.actuators["level"]) 
84
+    dict['npause'] = False 
85
+    
86
+def timer():
87
+    import GameLogic
88
+    import bge    
89
+
90
+    dict = bge.logic.globalDict    
91
+    
92
+    if dict['reload_timer'] == 1:
93
+        scene = bge.logic.getCurrentScene()
94
+            
95
+    if dict['reload_timer'] > 0:
96
+       dict['reload_timer'] -= 1         

+ 673
- 0
scripts/SortData.py View File

1
+#sort
2
+
3
+from bge import logic
4
+
5
+printDebug = True    #Set to True to see some basic debug info
6
+
7
+cont = logic.getCurrentController()
8
+own = cont.owner
9
+
10
+gameName = "shuvit"    #Set this to the name of your game!
11
+
12
+path = logic.expandPath(own["filePath"])
13
+
14
+positionList = []
15
+orientationList = []
16
+scaleList = []
17
+colorList = []
18
+stateList = []
19
+visibilityList = []
20
+skaterAnimList = []
21
+skaterAnimFList = []
22
+deckAnimList = []
23
+deckAnimFList = []
24
+srollVolList = []
25
+srollPitchList = []
26
+sgrind_cementVolList = []
27
+sgrind_cementPitchList = []
28
+sgrind_railVolList = []
29
+sgrind_railPitchList = []
30
+spopsoundList = []
31
+slandsoundList = []
32
+sdeckvisList = []
33
+positiontdList = []
34
+orientationtdList = []
35
+srevertsoundList = []
36
+
37
+allDataList = []
38
+allDataPath = path+gameName+" replay.dat"
39
+
40
+class writeData:
41
+
42
+    def addPosition(obj, pos, cut):
43
+        global positionList
44
+        positionList.append(" "+str(obj))
45
+        positionList.append(pos)
46
+        
47
+        if len(positionList) >= cut and cut > 0:
48
+            del positionList[0]
49
+            del positionList[0]
50
+        
51
+    def addOrientation(obj, ori, cut):
52
+        global orientationData
53
+        orientationList.append(" "+str(obj))
54
+        orientationList.append(ori)
55
+        
56
+        if len(orientationList) >= cut and cut > 0:
57
+            del orientationList[0]
58
+            del orientationList[0]
59
+        
60
+    def addScale(obj, sca, cut):
61
+        global scaleData
62
+        scaleList.append(" "+str(obj))
63
+        scaleList.append(sca)
64
+        
65
+        if len(scaleList) >= cut and cut > 0:
66
+            del scaleList[0]
67
+            del scaleList[0]
68
+        
69
+    def addColor(obj, col, cut):
70
+        global colorData
71
+        colorList.append(" "+str(obj))
72
+        colorList.append(col)
73
+        
74
+        if len(colorList) >= cut and cut > 0:
75
+            del colorList[0]
76
+            del colorList[0]
77
+        
78
+    def addState(obj, sta, cut):
79
+        global stateData
80
+        stateList.append(" "+str(obj))
81
+        stateList.append(sta)
82
+        
83
+        if len(stateList) >= cut and cut > 0:
84
+            del stateList[0]
85
+            del stateList[0]
86
+            
87
+    def addVisibility(obj, vis, cut):
88
+        global visibilityData
89
+        visibilityList.append(" "+str(obj))
90
+        visibilityList.append(vis)
91
+        if len(visibilityList) >= cut and cut > 0:
92
+            del visibilityList[0]
93
+            del visibilityList[0]
94
+    def addSkaterAnim(obj, anim, cut):
95
+        global skaterAnimData
96
+        skaterAnimList.append(" "+str(obj))
97
+        skaterAnimList.append(anim)
98
+        
99
+        if len(skaterAnimList) >= cut and cut > 0:
100
+            del skaterAnimList[0]
101
+            del skaterAnimList[0] 
102
+    def addSkaterAnimF(obj, animf, cut):
103
+        global skaterAnimFData
104
+        skaterAnimFList.append(" "+str(obj))
105
+        skaterAnimFList.append(animf)
106
+        
107
+        if len(skaterAnimFList) >= cut and cut > 0:
108
+            del skaterAnimFList[0]
109
+            del skaterAnimFList[0]  
110
+    def addDeckAnim(obj, anim, cut):
111
+        global deckAnimData
112
+        deckAnimList.append(" "+str(obj))
113
+        deckAnimList.append(anim)
114
+        
115
+        if len(deckAnimList) >= cut and cut > 0:
116
+            del deckAnimList[0]
117
+            del deckAnimList[0] 
118
+    def addDeckAnimF(obj, animf, cut):
119
+        global deckAnimFData
120
+        deckAnimFList.append(" "+str(obj))
121
+        deckAnimFList.append(animf)
122
+        
123
+        if len(deckAnimFList) >= cut and cut > 0:
124
+            del deckAnimFList[0]
125
+            del deckAnimFList[0]
126
+###             
127
+    def addSrollVol(obj, srollVol, cut):
128
+        global srollVolData
129
+        srollVolList.append(" "+str(obj))
130
+        srollVolList.append(srollVol)
131
+        if len(srollVolList) >= cut and cut > 0:
132
+            del srollVolList[0]
133
+            del srollVolList[0]
134
+    def addSrollPitch(obj, srollPitch, cut):
135
+        global srollPitchData
136
+        srollPitchList.append(" "+str(obj))
137
+        srollPitchList.append(srollPitch)
138
+        if len(srollPitchList) >= cut and cut > 0:
139
+            del srollPitchList[0]
140
+            del srollPitchList[0] 
141
+###             
142
+    def addSgrind_cementVol(obj, sgrind_cementVol, cut):
143
+        global sgrind_cementVolData
144
+        sgrind_cementVolList.append(" "+str(obj))
145
+        sgrind_cementVolList.append(sgrind_cementVol)
146
+        if len(sgrind_cementVolList) >= cut and cut > 0:
147
+            del sgrind_cementVolList[0]
148
+            del sgrind_cementVolList[0]
149
+    def addSgrind_cementPitch(obj, sgrind_cementPitch, cut):
150
+        global sgrind_cementPitchData
151
+        sgrind_cementPitchList.append(" "+str(obj))
152
+        sgrind_cementPitchList.append(sgrind_cementPitch)
153
+        if len(sgrind_cementPitchList) >= cut and cut > 0:
154
+            del sgrind_cementPitchList[0]
155
+            del sgrind_cementPitchList[0] 
156
+###             
157
+    def addSgrind_railVol(obj, sgrind_railVol, cut):
158
+        global sgrind_railVolData
159
+        sgrind_railVolList.append(" "+str(obj))
160
+        sgrind_railVolList.append(sgrind_railVol)
161
+        if len(sgrind_railVolList) >= cut and cut > 0:
162
+            del sgrind_railVolList[0]
163
+            del sgrind_railVolList[0]
164
+    def addSgrind_railPitch(obj, sgrind_railPitch, cut):
165
+        global sgrind_railPitchData
166
+        sgrind_railPitchList.append(" "+str(obj))
167
+        sgrind_railPitchList.append(sgrind_railPitch)
168
+        if len(sgrind_railPitchList) >= cut and cut > 0:
169
+            del sgrind_railPitchList[0]
170
+            del sgrind_railPitchList[0] 
171
+##
172
+    def addSpopsound(obj, spopsound, cut):
173
+        global spopsoundData
174
+        spopsoundList.append(" "+str(obj))
175
+        spopsoundList.append(spopsound)
176
+        if len(spopsoundList) >= cut and cut > 0:
177
+            del spopsoundList[0]
178
+            del spopsoundList[0] 
179
+##
180
+    def addSlandsound(obj, slandsound, cut):
181
+        global slandsoundData
182
+        slandsoundList.append(" "+str(obj))
183
+        slandsoundList.append(slandsound)
184
+        if len(slandsoundList) >= cut and cut > 0:
185
+            del slandsoundList[0]
186
+            del slandsoundList[0] 
187
+    
188
+    def addSdeckvis(obj, sdeckvis, cut):
189
+        global sdeckvisData
190
+        sdeckvisList.append(" "+str(obj))
191
+        sdeckvisList.append(sdeckvis)
192
+        if len(sdeckvisList) >= cut and cut > 0:
193
+            del sdeckvisList[0]
194
+            del sdeckvisList[0]     
195
+            
196
+    def addtdPosition(obj, pos, cut):
197
+        global positiontdList
198
+        positiontdList.append(" "+str(obj))
199
+        positiontdList.append(pos)
200
+        
201
+        if len(positiontdList) >= cut and cut > 0:
202
+            del positiontdList[0]
203
+            del positiontdList[0]
204
+        
205
+    def addtdOrientation(obj, ori, cut):
206
+        global orientationtdData
207
+        orientationtdList.append(" "+str(obj))
208
+        orientationtdList.append(ori)
209
+        
210
+        if len(orientationtdList) >= cut and cut > 0:
211
+            del orientationtdList[0]
212
+            del orientationtdList[0]  
213
+##
214
+    def addSrevertsound(obj, srevertsound, cut):
215
+        global srevertsoundData
216
+        srevertsoundList.append(" "+str(obj))
217
+        srevertsoundList.append(srevertsound)
218
+        if len(srevertsoundList) >= cut and cut > 0:
219
+            del srevertsoundList[0]
220
+            del srevertsoundList[0]                       
221
+                                                                                              
222
+            
223
+    def saveAll():
224
+
225
+        allDataList = ["game="+gameName+"\n",
226
+            " ".join(positionList),
227
+            " ".join(orientationList),
228
+            " ".join(scaleList),
229
+            " ".join(colorList),
230
+            " ".join(stateList),
231
+            " ".join(visibilityList),
232
+            " ".join(skaterAnimList),
233
+            " ".join(skaterAnimFList),
234
+            " ".join(deckAnimList),
235
+            " ".join(deckAnimFList),
236
+            " ".join(srollVolList),
237
+            " ".join(srollPitchList), 
238
+            " ".join(sgrind_cementVolList),
239
+            " ".join(sgrind_cementPitchList),
240
+            " ".join(sgrind_railVolList),
241
+            " ".join(sgrind_railPitchList),
242
+            " ".join(spopsoundList),
243
+            " ".join(slandsoundList),
244
+            " ".join(sdeckvisList),
245
+            " ".join(positiontdList),
246
+            " ".join(orientationtdList),
247
+            " ".join(spopsoundList)]    
248
+        try:
249
+            with open(allDataPath,'w') as all:
250
+                all.write("|".join(allDataList))
251
+                all.close()
252
+                if printDebug:
253
+                    print("State recording saved successfuly to "+allDataPath)
254
+        except IOError:
255
+            if printDebug:
256
+                print(allDataPath+"cannot be opened for writing")
257
+
258
+class readData:
259
+                                   
260
+    def loadAll():
261
+        
262
+        global allDataList
263
+        global positionList
264
+        global orientationList
265
+        global scaleList
266
+        global colorList
267
+        global stateList
268
+        global visibilityList
269
+        global skaterAnimList
270
+        global skaterAnimFList
271
+        global deckAnimList
272
+        global deckAnimFList 
273
+        global srollVolList
274
+        global srollPitchList 
275
+        global sgrind_cementVolList
276
+        global sgrind_cementPitchList 
277
+        global sgrind_railVolList
278
+        global sgrind_railPitchList
279
+        global spopsoundList
280
+        global slandsoundList 
281
+        global sdeckvisList     
282
+        global positiontdList
283
+        global orientationtdList 
284
+        global srevertsoundList                                          
285
+            
286
+        if not allDataList:
287
+            try:
288
+                with open(allDataPath) as all:
289
+                    data = all.read()
290
+                    all.close()
291
+
292
+                    allDataList = data.split("|",6)
293
+
294
+                    loadedGameName = str(allDataList[0].split("=",1)[1]).strip()
295
+                    try:
296
+                        if loadedGameName == gameName:
297
+
298
+                            positionList = allDataList[1].split()
299
+                            print('1')
300
+                            orientationList = allDataList[2].split()
301
+                            print('2')
302
+                            scaleList = allDataList[3].split()
303
+                            print('3')
304
+                            colorList = allDataList[4].split()
305
+                            print('4')
306
+                            stateList = allDataList[5].split()
307
+                            print('5')
308
+                            visibilityList = allDataList[6].split()
309
+                            print('6')
310
+                            skaterAnimList = allDataList[7].split()
311
+                            print('7')
312
+                            skaterAnimFList = allDataList[8].split()
313
+                            print('8')
314
+                            deckAnimList = allDataList[9].split()
315
+                            print('9')
316
+                            deckAnimFList = allDataList[10].split()
317
+                            print('1')
318
+                            srollVolList = allDataList[11].split()
319
+                            print('1')
320
+                            srollPitchList = allDataList[12].split()
321
+                            print('1')
322
+                            sgrind_cementVolList = allDataList[13].split()
323
+                            print('1')
324
+                            sgrind_cementPitchList = allDataList[14].split()
325
+                            print('1')
326
+                            sgrind_railVolList = allDataList[15].split() 
327
+                            print('1')
328
+                            sgrind_railPitchList = allDataList[16].split()
329
+                            print('1')
330
+                            spopsoundList = allDataList[17].split()
331
+                            print('1')
332
+                            slandsoundList = allDataList[18].split()
333
+                            print('1')
334
+                            sdeckvisList = allDataList[19].split()
335
+                            print('1')
336
+                            positiontdList = allDataList[20].split()
337
+                            print('1')
338
+                            orientationtdList = allDataList[21].split()  
339
+                            print('1')                          
340
+                            srevertsoundList = allDataList[22].split()
341
+                            print('1')
342
+                            
343
+                            if printDebug:
344
+                                print("Read file "+allDataPath)
345
+                    except Exception as e:
346
+                        print("error reading replay data", e)        
347
+            #except IOError:
348
+            except Exception as e:   
349
+                if printDebug:
350
+                    print("Error reading "+allDataPath, e)
351
+
352
+    def returnPosition(objIndex, valueIndex):
353
+        
354
+        if positionList:
355
+            name = positionList[objIndex-2]   #That -2 is a little workaround to a list index out of range error.
356
+            position = positionList[valueIndex-2]
357
+            name = name.replace(" ","")
358
+            position = str(position)
359
+            position = position.replace(","," ")
360
+            pX = float(position.split()[0])
361
+            pY = float(position.split()[1])
362
+            pZ = float(position.split()[2])
363
+            position = [pX,pY,pZ]
364
+            return(name, position)
365
+
366
+    def returnOrientation(objIndex, valueIndex):
367
+        if orientationList:
368
+            name = orientationList[objIndex-2]
369
+            orientation = orientationList[valueIndex-2]
370
+            name = name.replace(" ","")
371
+            orientation = str(orientation)
372
+            orientation = orientation.replace(","," ")
373
+            orientation = orientation.split()
374
+            return(name, orientation)
375
+
376
+    def returnScale(objIndex, valueIndex):
377
+
378
+        if scaleList:
379
+            name = scaleList[objIndex-2]
380
+            scale = scaleList[valueIndex-2]
381
+            
382
+            name = name.replace(" ","")
383
+            
384
+            scale = str(scale)
385
+            scale = scale.replace(","," ")
386
+            
387
+            sX = float(scale.split()[0])
388
+            sY = float(scale.split()[1])
389
+            sZ = float(scale.split()[2])
390
+            
391
+            scale = [sX,sY,sZ]
392
+
393
+            return(name, scale)
394
+
395
+    def returnColor(objIndex, valueIndex):
396
+
397
+        if colorList:
398
+            name = colorList[objIndex-2]
399
+            color = colorList[valueIndex-2]
400
+            
401
+            name = name.replace(" ","")
402
+            
403
+            color = str(color)
404
+            color = color.replace(","," ")
405
+            
406
+            cR = float(color.split()[0])
407
+            cG = float(color.split()[1])
408
+            cB = float(color.split()[2])
409
+            cA = float(color.split()[3])
410
+            
411
+            color = [cR,cG,cB,cA]
412
+
413
+            return(name, color)
414
+    
415
+    def returnState(objIndex, valueIndex):
416
+        
417
+        if stateList:
418
+            name = stateList[objIndex-2]
419
+            state = stateList[valueIndex-2]
420
+            
421
+            name = name.replace(" ","")
422
+            
423
+            state = str(state)
424
+            state = state.replace(","," ")
425
+            state = int(state)
426
+            
427
+            return(name, state)
428
+    
429
+    def returnVisibility(objIndex, valueIndex):
430
+        
431
+        if visibilityList:
432
+            name = visibilityList[objIndex-2]
433
+            visible = visibilityList[valueIndex-2]
434
+            
435
+            name = name.replace(" ","")
436
+            
437
+            visible = str(visible)
438
+            visible = visible.replace(","," ")
439
+            
440
+            return(name, visible)
441
+        
442
+    def returnSkaterAnim(objIndex, valueIndex):       
443
+        if skaterAnimList:
444
+            name = skaterAnimList[objIndex-2]
445
+            skaterAnim = skaterAnimList[valueIndex-2]
446
+            name = name.replace(" ","")           
447
+            skaterAnim = str(skaterAnim)
448
+            skaterAnim = skaterAnim.replace(","," ")           
449
+            return(name, skaterAnim) 
450
+        
451
+    def returnSkaterAnimF(objIndex, valueIndex):       
452
+        if skaterAnimFList:
453
+            name = skaterAnimFList[objIndex-2]
454
+            skaterAnimF = skaterAnimFList[valueIndex-2]
455
+            name = name.replace(" ","")
456
+            skaterAnimF = str(skaterAnimF)
457
+            skaterAnimF = skaterAnimF.replace(","," ")
458
+            return(name, skaterAnimF)  
459
+        
460
+    def returnDeckAnim(objIndex, valueIndex):    
461
+        if deckAnimList:
462
+            name = deckAnimList[objIndex-2]
463
+            deckAnim = deckAnimList[valueIndex-2]
464
+            name = name.replace(" ","")
465
+            deckAnim = str(deckAnim)
466
+            deckAnim = deckAnim.replace(","," ")
467
+            return(name, deckAnim) 
468
+        
469
+    def returnDeckAnimF(objIndex, valueIndex):
470
+        if deckAnimFList:
471
+            name = deckAnimFList[objIndex-2]
472
+            deckAnimF = deckAnimFList[valueIndex-2]
473
+            name = name.replace(" ","")
474
+            deckAnimF = str(deckAnimF)
475
+            deckAnimF = deckAnimF.replace(","," ")            
476
+            return(name, deckAnimF)
477
+####
478
+    def returnSrollVol(objIndex, valueIndex):
479
+        if srollVolList:
480
+            name = srollVolList[objIndex-2]
481
+            srollVol = srollVolList[valueIndex-2]
482
+            name = name.replace(" ","")
483
+            srollVol = str(srollVol)
484
+            srollVol = srollVol.replace(","," ")
485
+            srollVol = float(srollVol)
486
+            return(name, srollVol)
487
+        
488
+    def returnSrollPitch(objIndex, valueIndex):
489
+        if srollPitchList:
490
+            name = srollPitchList[objIndex-2]
491
+            srollPitch = srollPitchList[valueIndex-2]
492
+            name = name.replace(" ","")
493
+            srollPitch = str(srollPitch)
494
+            srollPitch = srollPitch.replace(","," ")
495
+            srollPitch = float(srollPitch)
496
+            return(name, srollPitch)                             ####
497
+####
498
+    def returnSgrind_cementVol(objIndex, valueIndex):
499
+        if sgrind_cementVolList:
500
+            name = sgrind_cementVolList[objIndex-2]
501
+            sgrind_cementVol = sgrind_cementVolList[valueIndex-2]
502
+            name = name.replace(" ","")
503
+            sgrind_cementVol = str(sgrind_cementVol)
504
+            sgrind_cementVol = sgrind_cementVol.replace(","," ")
505
+            sgrind_cementVol = float(sgrind_cementVol)
506
+            return(name, sgrind_cementVol)
507
+        
508
+    def returnSgrind_cementPitch(objIndex, valueIndex):
509
+        if sgrind_cementPitchList:
510
+            name = sgrind_cementPitchList[objIndex-2]
511
+            sgrind_cementPitch = sgrind_cementPitchList[valueIndex-2]
512
+            name = name.replace(" ","")
513
+            sgrind_cementPitch = str(sgrind_cementPitch)
514
+            sgrind_cementPitch = sgrind_cementPitch.replace(","," ")
515
+            sgrind_cementPitch = float(sgrind_cementPitch)
516
+            return(name, sgrind_cementPitch)                             ####              
517
+####
518
+    def returnSgrind_railVol(objIndex, valueIndex):
519
+        if sgrind_railVolList:
520
+            name = sgrind_railVolList[objIndex-2]
521
+            sgrind_railVol = sgrind_railVolList[valueIndex-2]
522
+            name = name.replace(" ","")
523
+            sgrind_railVol = str(sgrind_railVol)
524
+            sgrind_railVol = sgrind_railVol.replace(","," ")
525
+            sgrind_railVol = float(sgrind_railVol)
526
+            return(name, sgrind_railVol)
527
+        
528
+    def returnSgrind_railPitch(objIndex, valueIndex):
529
+        if sgrind_railPitchList:
530
+            name = sgrind_railPitchList[objIndex-2]
531
+            sgrind_railPitch = sgrind_railPitchList[valueIndex-2]
532
+            name = name.replace(" ","")
533
+            sgrind_railPitch = str(sgrind_railPitch)
534
+            sgrind_railPitch = sgrind_railPitch.replace(","," ")
535
+            sgrind_railPitch = float(sgrind_railPitch)
536
+            return(name, sgrind_railPitch)                             ####
537
+    def returnSpopsound(objIndex, valueIndex):
538
+        if spopsoundList:
539
+            name = spopsoundList[objIndex-2]
540
+            spopsound = spopsoundList[valueIndex-2]
541
+            name = name.replace(" ","")
542
+            spopsound = str(spopsound)
543
+            spopsound = spopsound.replace(","," ")
544
+            spopsound = int(spopsound)
545
+            return(name, spopsound)
546
+    def returnSlandsound(objIndex, valueIndex):
547
+        if slandsoundList:
548
+            name = slandsoundList[objIndex-2]
549
+            slandsound = slandsoundList[valueIndex-2]
550
+            name = name.replace(" ","")
551
+            slandsound = str(slandsound)
552
+            slandsound = slandsound.replace(","," ")
553
+            slandsound = int(slandsound)
554
+            return(name, slandsound) 
555
+    def returnSdeckvis(objIndex, valueIndex):
556
+        if sdeckvisList:
557
+            name = sdeckvisList[objIndex-2]
558
+            sdeckvis = sdeckvisList[valueIndex-2]
559
+            name = name.replace(" ","")
560
+            sdeckvis = str(sdeckvis)
561
+            sdeckvis = sdeckvis.replace(","," ")
562
+            sdeckvis = int(sdeckvis)
563
+            return(name, sdeckvis) 
564
+        
565
+    def returntdPosition(objIndex, valueIndex):
566
+        
567
+        if positiontdList:
568
+            name = positiontdList[objIndex-2]   #That -2 is a little workaround to a list index out of range error.
569
+            position = positiontdList[valueIndex-2]
570
+            name = name.replace(" ","")
571
+            position = str(position)
572
+            position = position.replace(","," ")
573
+            pX = float(position.split()[0])
574
+            pY = float(position.split()[1])
575
+            pZ = float(position.split()[2])
576
+            position = [pX,pY,pZ]
577
+            return(name, position)
578
+
579
+    def returntdOrientation(objIndex, valueIndex):
580
+        if orientationtdList:
581
+            name = orientationtdList[objIndex-2]
582
+            orientation = orientationtdList[valueIndex-2]
583
+            name = name.replace(" ","")
584
+            orientation = str(orientation)
585
+            orientation = orientation.replace(","," ")
586
+            orientation = orientation.split()
587
+            return(name, orientation)     
588
+        
589
+    def returnSrevertsound(objIndex, valueIndex):
590
+        if srevertsoundList:
591
+            name = srevertsoundList[objIndex-2]
592
+            srevertsound = srevertsoundList[valueIndex-2]
593
+            name = name.replace(" ","")
594
+            srevertsound = str(srevertsound)
595
+            srevertsound = srevertsound.replace(","," ")
596
+            srevertsound = int(srevertsound)
597
+            return(name, srevertsound)           
598
+                       
599
+####                
600
+
601
+    def getLengthPos():
602
+        if positionList:
603
+            return(len(positionList))
604
+
605
+    def getLengthOri():
606
+        if orientationList:
607
+            return(len(orientationList))
608
+
609
+    def getLengthSca():
610
+        if scaleList:
611
+            return(len(scaleList))
612
+
613
+    def getLengthCol():
614
+        if colorList:
615
+            return(len(colorList))
616
+    
617
+    def getLengthSta():
618
+        if stateList:
619
+            return(len(stateList))
620
+    
621
+    def getLengthVis():
622
+        if visibilityList:
623
+            return(len(visibilityList))
624
+    def getLengthSkaterAnim():
625
+        if skaterAnimList:
626
+            return(len(skaterAnimList)) 
627
+    def getLengthSkaterAnimF():
628
+        if skaterAnimFList:
629
+            return(len(skaterAnimFList)) 
630
+    def getLengthDeckAnim():
631
+        if deckAnimList:
632
+            return(len(deckAnimList)) 
633
+    def getLengthDeckAnimF():
634
+        if deckAnimFList:
635
+            return(len(deckAnimFList))
636
+    def getLengthSrollVol():
637
+        if srollVolList:
638
+            return(len(srollVolList)) 
639
+    def getLengthSrollPitch():
640
+        if srollPitchList:
641
+            return(len(srollPitchList)) 
642
+    def getLengthSgrind_cementVol():
643
+        if sgrind_cementVolList:
644
+            return(len(sgrind_cementVolList)) 
645
+    def getLengthSgrind_cementPitch():
646
+        if sgrind_cementPitchList:
647
+            return(len(sgrind_cementPitchList))
648
+    def getLengthSgrind_railVol():
649
+        if sgrind_railVolList:
650
+            return(len(sgrind_railVolList)) 
651
+    def getLengthSgrind_railPitch():
652
+        if sgrind_railPitchList:
653
+            return(len(sgrind_railPitchList))
654
+    def getLengthSpopsound():
655
+        if spopsoundList:
656
+            return(len(spopsoundList)) 
657
+    def getLengthSlandsound():
658
+        if slandsoundList:
659
+            return(len(slandsoundList)) 
660
+    def getLengthSdeckvis():
661
+        if sdeckvisList:
662
+            return(len(sdeckvisList))   
663
+    def getLengthtdPos():
664
+        if positiontdList:
665
+            return(len(positiontdList))
666
+    def getLengthtdOri():
667
+        if orientationtdList:
668
+            return(len(orientationtdList))
669
+    def getLengthSrevertsound():
670
+        if srevertsoundList:
671
+            return(len(srevertsoundList))    
672
+             
673
+                                                                                                    

+ 153
- 0
scripts/Startup.py View File

1
+import bge
2
+import GameLogic
3
+from bge import logic, render
4
+
5
+
6
+def main():
7
+    cont = GameLogic.getCurrentController() 
8
+    #cont = bge.logic.getCurrentController()
9
+    own = cont.owner
10
+    #bge.logic.addScene('Main')
11
+    scenes = bge.logic.getSceneList()
12
+    #print(scenes)
13
+#-------
14
+    #mainDir = GameLogic.expandPath("//")
15
+    #fileName = mainDir + "Settings.dat" 
16
+    #with open(fileName) as reading:
17
+            #data = [line.split()[0] for line in reading]
18
+            #data = reading.readlines()
19
+            #print lines[25]
20
+            #print lines[29]
21
+            #reading.close() 
22
+    #resx = int(data[7])
23
+    #resy = int(data[8]) 
24
+
25
+    #trick_string = dict.get('trick_string')                
26
+#    
27
+#    fullscreen = bge.render.getFullScreen()
28
+#    print("fullscreen = ", fullscreen)
29
+#    #if fullscreen != True:
30
+#        #bge.render.setFullScreen(True) 
31
+#    width = render.getWindowWidth()
32
+#    if width != resx:    
33
+#        bge.render.setWindowSize(resx, resy) 
34
+#---------
35
+    #bge.render.showFramerate
36
+    #bge.render.showProfile          
37
+    #dict = bge.logic.globalDict #Get the global dictionary
38
+    #print(dict)
39
+    #resx = dict['resx']
40
+    #resy = dict['resy']
41
+    #main_scene = [scene for scene in scenes if scene.name=="main"][0]
42
+#    
43
+#    for scene in scenes :
44
+#        if scene.name == 'Hud':
45
+#            player = scene.objects['player']
46
+#    print(scene.name)
47
+
48
+    #mains = main_scene.objects['Empty']
49
+    #resx = mains["resx"]
50
+    #resy = mains["resy"]
51
+    #print("read res: ", resx, resy)
52
+#    if not 'render_settings' in own:
53
+#        print("disable mips")
54
+#        render.setMipmapping(2)
55
+#    actu = cont.actuators['myActuator']
56
+#    cont.deactivate(actu)
57
+
58
+    for i in scenes:
59
+        if i.name == "main":
60
+            main = i
61
+            main.world.zenithColor = [0, 0, 0, 0]
62
+            main.world.horizonColor = [0, 0, 0, 0] 
63
+
64
+    scene = bge.logic.getCurrentScene()
65
+    black = scene.objects['black']
66
+    shuvit_logo = scene.objects['shuvit_logo']
67
+    black.playAction('black_fade', 0,100, layer=1, play_mode=0)
68
+    shuvit_logo.playAction('logo_fade', 0,100, layer=4, play_mode=0)  
69
+    print('black on') 
70
+    dict = bge.logic.globalDict
71
+    dict['overlay_fadein'] = 0
72
+    dict['overlay_fadeout'] = 0
73
+    dict['load_timer'] = 0
74
+    dict['reload_timer'] = 0
75
+    dict['menu_idle_timer'] = 0
76
+    if not any(logic.joysticks):
77
+        print("joystick not connnected")
78
+        dict['joy_con'] = 0
79
+    else:    
80
+        dict['joy_con'] = 1
81
+    dict['kb_a'] = 0
82
+    dict['kb_d'] = 0
83
+    dict['kb_w'] = 0
84
+    dict['kb_s'] = 0
85
+    dict['kb_q'] = 0
86
+    dict['kb_e'] = 0
87
+    dict['kb_z'] = 0
88
+    dict['kb_c'] = 0 
89
+    dict['kb_en'] = 0    
90
+    dict['kb_la'] = 0
91
+    dict['kb_ra'] = 0
92
+    dict['kb_ua'] = 0
93
+    dict['kb_da'] = 0 
94
+    dict['kb_lsh'] = 0
95
+    dict['kb_space'] = 0    
96
+    
97
+    dict['aBut'] = 0.0
98
+    dict['bBut'] = 0.0
99
+    dict['xBut'] = 0.0
100
+    dict['yBut'] = 0.0
101
+    dict['lBump'] = 0.0
102
+    dict['rBump'] = 0.0
103
+    dict['bkBut'] = 0.0
104
+    dict['stBut'] = 0.0
105
+    dict['xbBut'] = 0.0
106
+    dict['ltsBut'] = 0.0
107
+    dict['rtsBut'] = 0.0
108
+    dict['ldPad'] = 0.0
109
+    dict['rdPad'] = 0.0
110
+    dict['udPad'] = 0.0
111
+    dict['ddPad'] = 0.0
112
+    dict['rUD'] = 0.0
113
+    dict['lUD'] = 0.0
114
+    dict['rLR'] = 0.0
115
+    dict['lLR'] = 0.0
116
+    dict['rmUD'] = 0.0
117
+    dict['lmUD'] = 0.0
118
+    dict['rmLR'] = 0.0
119
+    dict['lmLR'] = 0.0
120
+    dict['mTrig'] = 0.0 
121
+    dict['lTrig'] = 0.0
122
+    dict['rTrig'] = 0.0 
123
+    
124
+    dict['last_ltsBut'] = 0.0
125
+    dict['last_rtsBut'] = 0.0   
126
+    dict['last_ldPad'] = 0 
127
+    
128
+    #dict['shirt_color'] = [.5,1,1,1]
129
+    
130
+    dict['mu_last_track'] = ''
131
+    dict['mu_artist'] = ''
132
+    dict['mu_title'] = ''    
133
+    
134
+    dict['joy_con'] = 1
135
+    dict['last_joy_con'] = 1
136
+    dict['last_driving'] = False
137
+    dict['driving_reset'] = False
138
+    
139
+    dict['spawned_npc_decks'] = []
140
+    dict['spawned_npc_trucks'] = []    
141
+    dict['spawned_npcs'] = []
142
+    #dict['JUMPHEIGHT'] = 800
143
+    #dict['MAX_VEL'] = 6.7
144
+    dict['char_loaded'] = 0
145
+    dict['man_sens_l'] = .03
146
+    dict['man_sens_r'] = .08
147
+    dict['walk'] = 1
148
+    dict['cur_ccH_targetHeight'] = .3
149
+    dict['music_start'] = False  
150
+    dict['npause'] = False
151
+    dict['playback'] = False  
152
+    
153
+main()

+ 12
- 0
scripts/active_camera_loc.py View File

1
+import bge
2
+
3
+
4
+def set(cont):
5
+    own = cont.owner
6
+
7
+    #own.getWorldPosition
8
+    scene = bge.logic.getCurrentScene()
9
+    cam = scene.active_camera
10
+    own.worldPosition = cam.worldPosition
11
+
12
+# dont call main(bge.logic.getCurrentController()), the py controller will

+ 576
- 0
scripts/aiRecord.py View File

1
+#record
2
+from bge import logic
3
+from mathutils import Vector
4
+from aiSortData import *
5
+import math
6
+
7
+cont = logic.getCurrentController()
8
+own = cont.owner
9
+scene = logic.getCurrentScene()
10
+cube = cont.owner
11
+#obj = scene.objects["control_cube.002"]
12
+#sound_empty = scene.objects['replay_sound_empty']
13
+#path = logic.expandPath(own["filePath"])
14
+dict = logic.globalDict
15
+PAF = 0
16
+DAF = 0
17
+
18
+npc_index = own['npc_index']
19
+#print(dict['spawned_npc_decks'], npc_index, 'spawned deck list')
20
+deck = dict['spawned_npc_decks'][npc_index]
21
+trucks = dict['spawned_npc_trucks'][npc_index]
22
+#deck = scene.objects[deck]
23
+
24
+#print(own.children)
25
+#deck = own.children['npc_ed_deck']
26
+#trucks = own.children["npc_ed_trucks"]
27
+
28
+#throw_deck_empty = scene.objects["throw_deck_empty"]
29
+#wheel1 = trucks.children["npc_ed_rollen.000"]
30
+#wheel2 = trucks.children["npc_ed_rollen.001"]
31
+#wheel3 = trucks.children["npc_ed_rollen.002"]
32
+#wheel4 = trucks.children["npc_ed_rollen.003"]
33
+
34
+#try:
35
+#    throw_deck = scene.objects['throw_deck']
36
+#except:
37
+#    throw_deck = None    
38
+
39
+#deckact = deck.actuators["Visibility"]
40
+#trucksact = trucks.actuators["Visibility"]
41
+#wheel1act = wheel1.actuators["Visibility"]
42
+#wheel2act = wheel2.actuators["Visibility"]
43
+#wheel3act = wheel3.actuators["Visibility"]
44
+#wheel4act = wheel4.actuators["Visibility"]
45
+
46
+class getData:
47
+
48
+
49
+
50
+    def savePosition(obj, cut):
51
+        position = [Vector(obj.worldPosition)[0],
52
+            Vector(obj.worldPosition)[1],
53
+            Vector(obj.worldPosition)[2]]
54
+        position = str(position).strip("[]")
55
+        position = position.replace(", ",",")
56
+        writeData.addPosition(obj, position, cut)
57
+     
58
+    def saveOrientation(obj, cut): 
59
+        orientation = [Vector(obj.localOrientation.to_euler())[0],
60
+            Vector(obj.localOrientation.to_euler())[1],
61
+            Vector(obj.localOrientation.to_euler())[2]]
62
+        orientation = str(orientation).strip("[]")
63
+        orientation = orientation.replace(", ",",")     
64
+        writeData.addOrientation(obj, orientation, cut)
65
+                    
66
+                                              
67
+              
68
+def loadData(cont, own):
69
+    
70
+    npc_index = own['npc_index']
71
+    #print(dict['spawned_npc_decks'], npc_index, 'spawned deck list')
72
+    deck = dict['spawned_npc_decks'][npc_index]
73
+    trucks = dict['spawned_npc_trucks'][npc_index]    
74
+    skater = dict['spawned_npcs'][npc_index]
75
+    cube = own 
76
+    #Function for loading the data from
77
+    #the disk and setting it.
78
+    #print('load_data', own)
79
+    objIndex = own["objIndex"]
80
+    #print(own['objIndex'], 'objindex')
81
+    own["valueIndex"] = objIndex + 1
82
+    valueIndex = own["valueIndex"]
83
+    playbackSpeed = own["playbackSpeed"]
84
+    loadedPosition = own["loadedPosition"]
85
+    loadedOrientation = own["loadedOrientation"]
86
+#    print(loadedPosition)
87
+#    loadedScale = own["loadedScale"]
88
+#    loadedColor = own["loadedColor"]
89
+#    loadedVisibility = own["loadedVisibility"]
90
+    loadedSkaterAnim = own["loadedSkaterAnim"]
91
+    loadedSkaterAnimf = own["loadedSkaterAnimF"]
92
+    loadedDeckAnim = own["loadedDeckAnim"]
93
+    loadedDeckAnimf = own["loadedDeckAnimF"]
94
+#    loadedSrollVol = own["loadedSrollVol"]
95
+#    loadedSrollPitch = own["loadedSrollPitch"]
96
+#    loadedSgrind_cementlVol = own["loadedSgrind_cementVol"]
97
+#    loadedSgrind_cementPitch = own["loadedSgrind_cementPitch"]
98
+#    loadedSgrind_railVol = own["loadedSgrind_railVol"]
99
+#    loadedSgrind_railPitch = own["loadedSgrind_railPitch"] 
100
+#    loadedSpopsound = own["loadedSpopsound"]            
101
+#    loadedSlandsound = own["loadedSlandsound"] 
102
+#    loadedSdeckvis = own["loadedSdeckvis"]  
103
+#    loadedtdPosition = own["loadedtdPosition"]
104
+#    loadedtdOrientation = own["loadedtdOrientation"]      
105
+#    loadedSrevertsound = own["loadedSrevertsound"] 
106
+       
107
+    #skater = own.children["npc_ed_arm"]
108
+    #deck = own.children["deck"]
109
+    #trucks = own.children["trucks"]
110
+    
111
+    num = 1
112
+    obj = own
113
+
114
+                     
115
+    readData.loadAll(own)    #Load the file!!!
116
+    
117
+    #-----Position-----#
118
+    own["lengthPos"] = readData.getLengthPos(own)
119
+    lengthPos = own["lengthPos"] 
120
+    positionList = own['positionList']
121
+    if lengthPos:
122
+        if objIndex > lengthPos-1:
123
+            own["objIndex"] = 0
124
+        if objIndex < 0:
125
+            own["objIndex"] = lengthPos-2
126
+
127
+        name, position = readData.returnPosition(objIndex, valueIndex, own)
128
+        name2, orientation = readData.returnOrientation(objIndex, valueIndex, own)
129
+        try:
130
+            if own['rpStartLoc_set'] == False:
131
+                
132
+                
133
+                
134
+                own['rpStartLoc'] = position
135
+                print('setting npc_start_pos', position)
136
+                
137
+                own['npc_playback'] = False
138
+                own['move'] = True
139
+                tracker = scene.addObject('npc_tracker', own, 0)
140
+                own['target_object_name'] = tracker
141
+                tracker.worldPosition = position
142
+                
143
+                oXYZ = own.localOrientation.to_euler()
144
+
145
+                oXYZ[0] = float(orientation[0])
146
+                oXYZ[1] = float(orientation[1])
147
+                oXYZ[2] = float(orientation[2])                
148
+                tracker.localOrientation = oXYZ.to_matrix()
149
+                rot = [ 0.0, 0.0, -1.570796327]
150
+                #tracker.applyRotation(rot,True) 
151
+    
152
+                rotz = math.degrees(oXYZ[2])
153
+                rotz -= 90
154
+                if rotz < -180:
155
+                    rotz = rotz + 360
156
+                own['rpStartZ'] = rotz               
157
+                
158
+            else:  
159
+                cube.worldPosition = position
160
+                deck.worldPosition = position
161
+                trucks.worldPosition = position
162
+                
163
+            if 'data_loaded' not in own:
164
+                own['data_loaded'] = 1 
165
+                cube.worldPosition = position
166
+                deck.worldPosition = position
167
+                trucks.worldPosition = position                   
168
+                
169
+        except:
170
+            print('npc positioning not working')
171
+            #pass
172
+    #-----Orientation-----#
173
+    own["lengthOri"] = readData.getLengthOri(own)   
174
+    lengthOri = own["lengthOri"]
175
+
176
+    valueIndex = own['valueIndex']
177
+    #print(valueIndex, objIndex, 'value Index')
178
+    #if lengthPos:
179
+    if lengthOri:
180
+        if valueIndex > lengthOri-1:
181
+            own["valueIndex"] = 0
182
+        if objIndex < 0:
183
+            own["objIndex"] = lengthOri-2
184
+        name, orientation = readData.returnOrientation(objIndex, valueIndex, own)
185
+        oXYZ = own.localOrientation.to_euler()
186
+        oXYZ[0] = float(orientation[0])
187
+        oXYZ[1] = float(orientation[1])
188
+        oXYZ[2] = float(orientation[2])    
189
+        try:
190
+            if own['rpStartLoc_set'] == True:
191
+                own.localOrientation = oXYZ.to_matrix()
192
+                deck.localOrientation = oXYZ.to_matrix()
193
+                trucks.localOrientation = oXYZ.to_matrix()
194
+                rot = [ 0.0, 0.0, -1.570796327]
195
+                own.applyRotation(rot,True) 
196
+            else:
197
+                own['rpStartLoc_set'] = True
198
+        except:
199
+            print('npc orientation not working')
200
+#    #-----Scale-----#
201
+#    own["lengthSca"] = readData.getLengthSca()
202
+#    lengthSca = own["lengthSca"]
203
+#    
204
+#    if lengthSca:
205
+#    
206
+#        if valueIndex > lengthSca-1:
207
+#            own["valueIndex"] = 0
208
+#        if objIndex < 0:
209
+#            own["objIndex"] = lengthSca-2
210
+#       
211
+#        name, scale = readData.returnScale(objIndex, valueIndex)
212
+#        
213
+#        if name in scene.objects:
214
+#            try:
215
+#                scene.objects[name].localScale = scale
216
+#            except:
217
+#                pass
218
+#    #-----Color-----#
219
+#    own["lengthCol"] = readData.getLengthCol()   
220
+#    lengthCol = own["lengthCol"]
221
+#    
222
+#    if lengthCol:
223
+
224
+#        if valueIndex > lengthCol-1:
225
+#            own["valueIndex"] = 0
226
+#        if objIndex < 0:
227
+#            own["objIndex"] = lengthCol-2
228
+
229
+#        name, color = readData.returnColor(objIndex, valueIndex)
230
+#        
231
+#        if name in scene.objects:
232
+#            try:
233
+#                scene.objects[name].color = color
234
+#            except:
235
+#                pass
236
+#    #-----Visibility-----#
237
+#    own["lengthVis"] = readData.getLengthVis()
238
+#    lengthVis = own["lengthVis"]
239
+#    
240
+#    if lengthVis:
241
+
242
+#        if valueIndex > lengthVis-1:
243
+#            own["valueIndex"] = 0
244
+#        if objIndex < 0:
245
+#            own["objIndex"] = lengthVis-2
246
+
247
+#        name, visible = readData.returnVisibility(objIndex, valueIndex)
248
+#        
249
+#        if name in scene.objects:
250
+#            try:
251
+#                scene.objects[name].visible = int(visible)
252
+#            except:
253
+#                pass
254
+    #-----Skater Animation Name-----#
255
+    own["lengthSkaterAnim"] = readData.getLengthSkaterAnim(own)
256
+    lengthSkaterAnim = own["lengthSkaterAnim"]
257
+    #print("lengthskateranim", lengthSkaterAnim)
258
+    if lengthSkaterAnim:
259
+
260
+        if valueIndex > lengthSkaterAnim-1:
261
+            own["valueIndex"] = 0
262
+        if objIndex < 0:
263
+            own["objIndex"] = lengthSkaterAnim-2
264
+
265
+        name, skateranim = readData.returnSkaterAnim(objIndex, valueIndex, own)
266
+        name, PAF = readData.returnSkaterAnimF(objIndex, valueIndex, own)
267
+        PAF = round(float(PAF), 1)
268
+        #print(valueIndex, skateranim, PAF,  'sa')
269
+        PAF = float(PAF)
270
+        if skater in own.children:
271
+            #print("name in")
272
+            try:
273
+                skater.stopAction(0)
274
+                skater.stopAction(1)
275
+                skater.stopAction(2)
276
+                skater.stopAction(3)
277
+                skater.stopAction(9999)
278
+                if skater != '' and skateranim != 'control_cube.002':
279
+                    skater.playAction(skateranim, PAF,PAF, layer=2, play_mode=1, speed=1)
280
+                #print("Playing: ", skater, skateranim, PAF)
281
+            except:
282
+                print("something is wrong")
283
+                
284
+    #-----Deck Animation Name-----#
285
+    own["lengthDeckAnim"] = readData.getLengthDeckAnim(own)
286
+    lengthDeckAnim = own["lengthDeckAnim"]
287
+    #print("lengthDeckanim", lengthDeckAnim)
288
+    if lengthDeckAnim:
289
+
290
+        if valueIndex > lengthDeckAnim-1:
291
+            own["valueIndex"] = 0
292
+        if objIndex < 0:
293
+            own["objIndex"] = lengthDeckAnim-2
294
+
295
+        name, deckanim = readData.returnDeckAnim(objIndex, valueIndex, own)
296
+        name, DAF = readData.returnDeckAnimF(objIndex, valueIndex, own)
297
+        name = 'npc_ed_deck'
298
+
299
+        DAF = float(DAF)
300
+        if deck in own.children:
301
+            #print("name in")
302
+            try:
303
+                if deck != '' and deckanim != 'control_cube.002':
304
+                    deck.playAction(deckanim, DAF,DAF, layer=2, play_mode=1, speed=1)
305
+                    trucks.playAction(deckanim, DAF,DAF, layer=2, play_mode=1, speed=1)
306
+                #print("Playing: ", deckanim, PAF)
307
+                #print("Playing: ", deck, deckanim, DAF)
308
+            except:
309
+                print("deck something is wrong")
310
+                #pass  
311
+
312
+##
313
+#    #-----sroll-----#
314
+#    own["lengthSrollVol"] = readData.getLengthSrollVol()
315
+#    lengthSrollVol = own["lengthSrollVol"]
316
+#    if lengthSrollVol:
317
+#        if valueIndex > lengthSrollVol-1:
318
+#            own["valueIndex"] = 0
319
+#        if objIndex < 0:
320
+#            own["objIndex"] = lengthSrollVol-2
321
+#        name, srollVol = readData.returnSrollVol(objIndex, valueIndex)
322
+#        name, srollPitch = readData.returnSrollPitch(objIndex, valueIndex)    
323
+#        if name in scene.objects:
324
+#            try:
325
+#                cube = scene.objects["control_cube.002"]
326
+#                srollVol = round(srollVol, 2)
327
+#                act = cube.actuators["sroll"]
328
+#                if srollVol < .12:
329
+#                    act.volume = srollVol
330
+#                    act.pitch = srollPitch
331
+#                act.startSound()
332
+#            except:
333
+#                pass
334
+####            
335
+##
336
+#    #-----grind cement-----#
337
+#    own["lengthSgrind_cementVol"] = readData.getLengthSgrind_cementVol()
338
+#    lengthSgrind_cementVol = own["lengthSgrind_cementVol"]
339
+#    if lengthSgrind_cementVol:
340
+#        if valueIndex > lengthSgrind_cementVol-1:
341
+#            own["valueIndex"] = 0
342
+#        if objIndex < 0:
343
+#            own["objIndex"] = lengthSgrind_cementVol-2
344
+#        name, sgrind_cementVol = readData.returnSgrind_cementVol(objIndex, valueIndex)
345
+#        name, sgrind_cementPitch = readData.returnSgrind_cementPitch(objIndex, valueIndex)    
346
+#        if name in scene.objects:
347
+#            try:
348
+#                cube = scene.objects["control_cube.002"]
349
+#                sgrind_cementVol = round(sgrind_cementVol, 2)
350
+#                act = cube.actuators["grind_cement"]
351
+#                if sgrind_cementVol < .2:
352
+#                    act.volume = sgrind_cementVol
353
+#                    act.pitch = sgrind_cementPitch
354
+#                act.startSound()
355
+#                
356
+#            except:
357
+#                pass
358
+####    
359
+##
360
+#    #-----grind rail-----#
361
+#    own["lengthSgrind_railVol"] = readData.getLengthSgrind_railVol()
362
+#    lengthSgrind_railVol = own["lengthSgrind_railVol"]
363
+#    if lengthSgrind_railVol:
364
+#        if valueIndex > lengthSgrind_railVol-1:
365
+#            own["valueIndex"] = 0
366
+#        if objIndex < 0:
367
+#            own["objIndex"] = lengthSgrind_railVol-2
368
+#        name, sgrind_railVol = readData.returnSgrind_railVol(objIndex, valueIndex)
369
+#        name, sgrind_railPitch = readData.returnSgrind_railPitch(objIndex, valueIndex)    
370
+#        if name in scene.objects:
371
+#            try:
372
+#                cube = scene.objects["control_cube.002"]
373
+#                sgrind_railVol = round(sgrind_railVol, 2)
374
+#                act = cube.actuators["grind_rail"]
375
+#                if sgrind_railVol < .2:
376
+#                    act.volume = sgrind_railVol
377
+#                    act.pitch = sgrind_railPitch
378
+#                act.startSound()
379
+#                #print("grindsound = ", sgrind_railVol, sgrind_railPitch)
380
+#            except:
381
+#                pass
382
+####  
383
+##
384
+#    #-----pop sound-----#
385
+#    own["lengthSpopsound"] = readData.getLengthSpopsound()
386
+#    lengthSpopsound = own["lengthSpopsound"]
387
+#    if lengthSpopsound:
388
+#        if valueIndex > lengthSpopsound-1:
389
+#            own["valueIndex"] = 0
390
+#        if objIndex < 0:
391
+#            own["objIndex"] = lengthSpopsound-2
392
+#        name, spopsound = readData.returnSpopsound(objIndex, valueIndex)   
393
+#        if name in scene.objects:
394
+#            #act = sound_empty.actuators["pop"]
395
+#            try:
396
+#                #cube = scene.objects[sound_empty]
397
+#                spopsound = round(spopsound, 2)
398
+#                act = cube.actuators["pop"]
399
+#                #act = sound_empty.actuators["pop"]
400
+#                if spopsound == 1:
401
+#                    #act.volume_maximum = .7
402
+#                    #act.is3D = True
403
+#                    #act.distance_reference = 10.0
404
+#                    #act.distance_maximum = 50.0
405
+#                    act.volume = .6
406
+#                    act.startSound()
407
+#                #print("grindsound = ", spopsound, sgrind_railPitch)
408
+#            except:
409
+#                print("sound passed")
410
+#                pass
411
+####
412
+##
413
+#    #-----land sound-----#
414
+#    own["lengthSlandsound"] = readData.getLengthSlandsound()
415
+#    lengthSlandsound = own["lengthSlandsound"]
416
+#    if lengthSlandsound:
417
+#        if valueIndex > lengthSlandsound-1:
418
+#            own["valueIndex"] = 0
419
+#        if objIndex < 0:
420
+#            own["objIndex"] = lengthSlandsound-2
421
+#        name, slandsound = readData.returnSlandsound(objIndex, valueIndex)   
422
+#        if name in scene.objects:
423
+#            try:
424
+#                cube = scene.objects["control_cube.002"]
425
+#                slandsound = round(slandsound, 2)
426
+#                act = cube.actuators["land"]
427
+#                if slandsound == 1:
428
+#                    act.volume = .6
429
+#                    act.startSound()
430
+#                #print("grindsound = ", slandsound, sgrind_railPitch)
431
+#            except:
432
+#                pass
433
+####  
434
+####
435
+##
436
+#    #-----land sound-----#
437
+#    own["lengthSdeckvis"] = readData.getLengthSdeckvis()
438
+#    lengthSdeckvis = own["lengthSdeckvis"]
439
+#    if lengthSdeckvis:
440
+#        if valueIndex > lengthSdeckvis-1:
441
+#            own["valueIndex"] = 0
442
+#        if objIndex < 0:
443
+#            own["objIndex"] = lengthSdeckvis-2
444
+#        name, sdeckvis = readData.returnSdeckvis(objIndex, valueIndex)   
445
+#        
446
+#        
447
+#        if name in scene.objects:
448
+#            try:
449
+#                cube = scene.objects["control_cube.002"]
450
+#                if sdeckvis == 1:
451
+#                    #print('setting deck visible')
452
+#                    deckact.visibility = True
453
+#                    trucksact.visibility = True
454
+#                    wheel1act.visibility = True
455
+#                    wheel2act.visibility = True
456
+#                    wheel3act.visibility = True
457
+#                    wheel4act.visibility = True   
458
+#                    cont.activate(deck.actuators['Visibility'])
459
+#                    cont.activate(trucks.actuators['Visibility'])
460
+#                    cont.activate(wheel1.actuators['Visibility'])
461
+#                    cont.activate(wheel2.actuators['Visibility'])
462
+#                    cont.activate(wheel3.actuators['Visibility'])
463
+#                    cont.activate(wheel4.actuators['Visibility'])  
464
+#                    for n in scene.objects:
465
+#                        if 'throw_deck' in n.name and 'empty' not in n.name:
466
+#                            n.endObject() 
467
+##                    if 'throw_deck' in scene.objects:
468
+#                            #print('ending td', n)
469
+#                            cont.activate(throw_deck.actuators['end_throw_deck'])                   
470
+#                     
471
+#                    #throwdeck.visibility = False                               
472
+#                else:
473
+#                    #print('setting deck invisible')
474
+#                    deckact.visibility = False
475
+#                    trucksact.visibility = False
476
+#                    wheel1act.visibility = False
477
+#                    wheel2act.visibility = False
478
+#                    wheel3act.visibility = False
479
+#                    wheel4act.visibility = False   
480
+#                    cont.activate(deck.actuators['Visibility'])
481
+#                    cont.activate(trucks.actuators['Visibility'])
482
+#                    cont.activate(wheel1.actuators['Visibility'])
483
+#                    cont.activate(wheel2.actuators['Visibility'])
484
+#                    cont.activate(wheel3.actuators['Visibility'])
485
+#                    cont.activate(wheel4.actuators['Visibility'])  
486
+#                    #if throw_deck == None:
487
+#                    if 'throw_deck' not in scene.objects:
488
+#                        #print('no throwdeck')
489
+#                        #cont.deactivate(throw_deck.actuators['end_throw_deck']) 
490
+#                        #throw_deck_empty.wordPosition.z = throw_deck_empty.wordPosition.z + 1
491
+#                        cont.activate(throw_deck_empty.actuators['throw_dec_act']) 
492
+#                        #scene.addObject('throw_deck')
493
+#                    #throwdeck.visibility = True
494
+#                    throw_deck.suspendDynamics()
495
+
496
+#            except:
497
+#                pass
498
+###    
499
+#    #-----Position-----#
500
+#    own["lengthtdPos"] = readData.getLengthtdPos()
501
+#    lengthPos = own["lengthtdPos"] 
502
+#    
503
+#    if lengthPos:
504
+#        
505
+#        if objIndex > lengthPos-1:
506
+#            own["objIndex"] = 0
507
+#        if objIndex < 0:
508
+#            own["objIndex"] = lengthPos-2
509
+
510
+#        name, position = readData.returntdPosition(objIndex, valueIndex)
511
+#        name = 'throw_deck'
512
+#        if name in scene.objects:
513
+#            try:
514
+#                scene.objects[name].worldPosition = position
515
+#                #print('recording tdPos', position)
516
+#            except:
517
+#                pass
518
+#    #-----Orientation-----#
519
+#    own["lengthtdOri"] = readData.getLengthtdOri()   
520
+#    lengthOri = own["lengthtdOri"]
521
+#    
522
+#    #if lengthPos:
523
+#    if lengthOri:
524
+#  
525
+#        if valueIndex > lengthOri-1:
526
+#            own["valueIndex"] = 0
527
+#        if objIndex < 0:
528
+#            own["objIndex"] = lengthOri-2
529
+
530
+#        name, orientation = readData.returntdOrientation(objIndex, valueIndex)
531
+#        name = 'throw_deck'
532
+#        if name in scene.objects:
533
+#            
534
+#            oXYZ = scene.objects[name].localOrientation.to_euler()
535
+
536
+#            oXYZ[0] = float(orientation[0])
537
+#            oXYZ[1] = float(orientation[1])
538
+#            oXYZ[2] = float(orientation[2])
539
+#            
540
+#            try:
541
+#                #print('recording tdOri')
542
+#                scene.objects[name].localOrientation = oXYZ.to_matrix()
543
+#            except:
544
+#                pass
545
+
546
+##
547
+#    #-----revert sound-----#
548
+#    own["lengthSrevertsound"] = readData.getLengthSrevertsound()
549
+#    lengthSrevertsound = own["lengthSrevertsound"]
550
+#    if lengthSrevertsound:
551
+#        if valueIndex > lengthSrevertsound-1:
552
+#            own["valueIndex"] = 0
553
+#        if objIndex < 0:
554
+#            own["objIndex"] = lengthSrevertsound-2
555
+#        name, srevertsound = readData.returnSrevertsound(objIndex, valueIndex)   
556
+#        if name in scene.objects:
557
+#            try:
558
+#                #cube = scene.objects[sound_empty]
559
+#                srevertsound = round(srevertsound, 2)
560
+#                act = cube.actuators["revertSound"]
561
+#                if srevertsound == 1:
562
+#                    act.startSound()
563
+#                #print("grindsound = ", spopsound, sgrind_railPitch)
564
+#            except:
565
+#                print("sound passed")
566
+#                pass
567
+
568
+                                            
569
+                       
570
+def main(recording_cutoff, cc):
571
+    pass
572
+              
573
+            
574
+         
575
+def breakOut():
576
+    pass

+ 553
- 0
scripts/aiSortData.py View File

1
+from bge import logic
2
+
3
+printDebug = True    #Set to True to see some basic debug info
4
+
5
+cont = logic.getCurrentController()
6
+own = cont.owner
7
+
8
+gameName = "shuvit"    #Set this to the name of your game!
9
+
10
+path = logic.expandPath(own["filePath"])
11
+
12
+positionList = []
13
+orientationList = []
14
+scaleList = []
15
+colorList = []
16
+stateList = []
17
+visibilityList = []
18
+skaterAnimList = []
19
+skaterAnimFList = []
20
+deckAnimList = []
21
+deckAnimFList = []
22
+srollVolList = []
23
+srollPitchList = []
24
+sgrind_cementVolList = []
25
+sgrind_cementPitchList = []
26
+sgrind_railVolList = []
27
+sgrind_railPitchList = []
28
+spopsoundList = []
29
+slandsoundList = []
30
+sdeckvisList = []
31
+positiontdList = []
32
+orientationtdList = []
33
+srevertsoundList = []
34
+
35
+allDataList = []
36
+allDataPath = path+ own['npc_replay_name']
37
+
38
+      
39
+
40
+class readData:
41
+                                   
42
+    def loadAll(own):
43
+#        
44
+#        global allDataList
45
+#        global positionList
46
+#        global orientationList
47
+#        global scaleList
48
+#        global colorList
49
+#        global stateList
50
+#        global visibilityList
51
+#        global skaterAnimList
52
+#        global skaterAnimFList
53
+#        global deckAnimList
54
+#        global deckAnimFList 
55
+#        global srollVolList
56
+#        global srollPitchList 
57
+#        global sgrind_cementVolList
58
+#        global sgrind_cementPitchList 
59
+#        global sgrind_railVolList
60
+#        global sgrind_railPitchList
61
+#        global spopsoundList
62
+#        global slandsoundList 
63
+#        global sdeckvisList     
64
+#        global positiontdList
65
+#        global orientationtdList 
66
+#        global srevertsoundList  
67
+
68
+#        own['allDataList'] = []
69
+#        own['positionList'] = []
70
+#        own['orientationList'] = []
71
+#        own['scaleList'] = []
72
+#        own['colorList'] = []
73
+#        own['stateList'] = []
74
+#        own['visibilityList'] = []
75
+#        own['skaterAnimList'] = []
76
+#        own['skaterAnimFList'] = []
77
+#        own['deckAnimList'] = []
78
+#        own['deckAnimFList'] = []
79
+#        own['srollVolList'] = []
80
+#        own['srollPitchList']  = []
81
+#        own['sgrind_cementVolList'] = []
82
+#        own['sgrind_cementPitchList']  = []
83
+#        own['sgrind_railVolList'] = []
84
+#        own['sgrind_railPitchList'] = []
85
+#        own['spopsoundList'] = []
86
+#        own['slandsoundList']  = []
87
+#        own['sdeckvisList'] = []
88
+#        own['positiontdList'] = []
89
+#        own['orientationtdList']  = []
90
+#        own['srevertsoundList']  = []
91
+        
92
+        allDataPath = path+ own['npc_replay_name']    
93
+        
94
+        #if not allDataList:
95
+        if own['inited'] == False:
96
+            #own['inited'] = True
97
+            try:
98
+                with open(allDataPath) as all:
99
+                    data = all.read()
100
+                    all.close()
101
+
102
+                    allDataList = data.split("|",22)#6)
103
+                    own['allDataList'] = allDataList
104
+                    loadedGameName = str(allDataList[0].split("=",1)[1]).strip()
105
+            
106
+                    #skaterAnimList = allDataList[7].split()
107
+                    #skaterAnimFList = allDataList[8].split()                    
108
+                    
109
+                    try:
110
+                        if loadedGameName == gameName:
111
+
112
+#                            positionList = allDataList[1].split()
113
+#                            orientationList = allDataList[2].split()
114
+#                            scaleList = allDataList[3].split()
115
+#                            colorList = allDataList[4].split()
116
+#                            stateList = allDataList[5].split()
117
+#                            visibilityList = allDataList[6].split()
118
+#                            skaterAnimList = allDataList[7].split()
119
+#                            skaterAnimFList = allDataList[8].split()
120
+#                            deckAnimList = allDataList[9].split()
121
+#                            deckAnimFList = allDataList[10].split()
122
+#                            srollVolList = allDataList[11].split()
123
+#                            srollPitchList = allDataList[12].split()
124
+#                            sgrind_cementVolList = allDataList[13].split()
125
+#                            sgrind_cementPitchList = allDataList[14].split()
126
+#                            sgrind_railVolList = allDataList[15].split() 
127
+#                            sgrind_railPitchList = allDataList[16].split()
128
+#                            spopsoundList = allDataList[17].split()
129
+#                            slandsoundList = allDataList[18].split()
130
+#                            sdeckvisList = allDataList[19].split()
131
+#                            positiontdList = allDataList[20].split()
132
+#                            orientationtdList = allDataList[21].split() 
133
+#                            srevertsoundList = allDataList[22].split()
134
+#                            
135
+                            own['positionList'] = allDataList[1].split()
136
+                            own['orientationList'] = allDataList[2].split()
137
+                            own['scaleList'] = allDataList[3].split()
138
+                            own['colorList'] = allDataList[4].split()
139
+                            own['stateList'] = allDataList[5].split()
140
+                            own['visibilityList'] = allDataList[6].split()
141
+                            own['skaterAnimList'] = allDataList[7].split()
142
+                            own['skaterAnimFList'] = allDataList[8].split()
143
+                            own['deckAnimList'] = allDataList[9].split()
144
+                            own['deckAnimFList'] = allDataList[10].split()
145
+                            own['srollVolList'] = allDataList[11].split()
146
+                            own['srollPitchList'] = allDataList[12].split()
147
+                            own['sgrind_cementVolList'] = allDataList[13].split()
148
+                            own['sgrind_cementPitchList'] = allDataList[14].split()
149
+                            own['sgrind_railVolList'] = allDataList[15].split() 
150
+                            own['sgrind_railPitchList'] = allDataList[16].split()
151
+                            own['spopsoundList'] = allDataList[17].split()
152
+                            own['slandsoundList'] = allDataList[18].split()
153
+                            own['sdeckvisList'] = allDataList[19].split()
154
+                            own['positiontdList'] = allDataList[20].split()
155
+                            own['orientationtdList'] = allDataList[21].split() 
156
+                            own['srevertsoundList'] = allDataList[22].split()             
157
+                            
158
+                            
159
+                            
160
+
161
+                            positionList = own['positionList'
162
+                            ]
163
+                            orientationList = own['orientationList']
164
+                            scaleList = own['scaleList']
165
+                            colorList = own['colorList']
166
+                            stateList = own['stateList']
167
+                            visibilityList = own['visibilityList']
168
+                            skaterAnimList = own['skaterAnimList']
169
+                            skaterAnimFList = own['skaterAnimFList']
170
+                            deckAnimList = own['deckAnimList']
171
+                            deckAnimFList = own['deckAnimFList']
172
+                            srollVolList = own['srollVolList']
173
+                            srollPitchList = own['srollPitchList']
174
+                            sgrind_cementVolList = own['sgrind_cementVolList']
175
+                            sgrind_cementPitchList = own['sgrind_cementPitchList']
176
+                            sgrind_railVolList = own['sgrind_railVolList']
177
+                            sgrind_railPitchList = own['sgrind_railPitchList']
178
+                            spopsoundList = own['spopsoundList']
179
+                            slandsoundList = own['slandsoundList']
180
+                            sdeckvisList = own['sdeckvisList']
181
+                            positiontdList = own['positiontdList']
182
+                            orientationtdList = own['orientationtdList']
183
+                            srevertsoundList = own['srevertsoundList']
184
+                                                        
185
+                            
186
+                                           
187
+                            
188
+                            if printDebug:
189
+                                print("Read file "+allDataPath)
190
+                                own['inited'] = True
191
+                    except:
192
+                        print("error reading replay data")        
193
+            except IOError:
194
+                if printDebug:
195
+                    print("Error reading "+allDataPath)
196
+
197
+    def returnPosition(objIndex, valueIndex, own):
198
+        positionList = own['positionList']
199
+        if positionList:
200
+            name = positionList[objIndex-2]   #That -2 is a little workaround to a list index out of range error.
201
+            
202
+            position = positionList[valueIndex-2]
203
+            name = name.replace(" ","")
204
+            #print(position)
205
+            position = str(position)
206
+            position = position.replace(","," ")
207
+            pX = float(position.split()[0])
208
+            pY = float(position.split()[1])
209
+            pZ = float(position.split()[2])
210
+            position = [pX,pY,pZ]
211
+            #print(name, position)
212
+            return(name, position)
213
+
214
+    def returnOrientation(objIndex, valueIndex, own):
215
+        orientationList = own['orientationList']
216
+        if orientationList:
217
+            name = orientationList[objIndex-2]
218
+            orientation = orientationList[valueIndex-2]
219
+            name = name.replace(" ","")
220
+            orientation = str(orientation)
221
+            orientation = orientation.replace(","," ")
222
+            orientation = orientation.split()
223
+            return(name, orientation)
224
+
225
+    def returnScale(objIndex, valueIndex):
226
+
227
+        if scaleList:
228
+            name = scaleList[objIndex-2]
229
+            scale = scaleList[valueIndex-2]
230
+            
231
+            name = name.replace(" ","")
232
+            
233
+            scale = str(scale)
234
+            scale = scale.replace(","," ")
235
+            
236
+            sX = float(scale.split()[0])
237
+            sY = float(scale.split()[1])
238
+            sZ = float(scale.split()[2])
239
+            
240
+            scale = [sX,sY,sZ]
241
+
242
+            return(name, scale)
243
+
244
+    def returnColor(objIndex, valueIndex):
245
+
246
+        if colorList:
247
+            name = colorList[objIndex-2]
248
+            color = colorList[valueIndex-2]
249
+            
250
+            name = name.replace(" ","")
251
+            
252
+            color = str(color)
253
+            color = color.replace(","," ")
254
+            
255
+            cR = float(color.split()[0])
256
+            cG = float(color.split()[1])
257
+            cB = float(color.split()[2])
258
+            cA = float(color.split()[3])
259
+            
260
+            color = [cR,cG,cB,cA]
261
+
262
+            return(name, color)
263
+    
264
+    def returnState(objIndex, valueIndex):
265
+        
266
+        if stateList:
267
+            name = stateList[objIndex-2]
268
+            state = stateList[valueIndex-2]
269
+            
270
+            name = name.replace(" ","")
271
+            
272
+            state = str(state)
273
+            state = state.replace(","," ")
274
+            state = int(state)
275
+            
276
+            return(name, state)
277
+    
278
+    def returnVisibility(objIndex, valueIndex):
279
+        
280
+        if visibilityList:
281
+            name = visibilityList[objIndex-2]
282
+            visible = visibilityList[valueIndex-2]
283
+            
284
+            name = name.replace(" ","")
285
+            
286
+            visible = str(visible)
287
+            visible = visible.replace(","," ")
288
+            
289
+            return(name, visible)
290
+        
291
+    def returnSkaterAnim(objIndex, valueIndex, own):  
292
+        #print('getting anim list') 
293
+        #print(objIndex-2)     
294
+        skaterAnimList = own['skaterAnimList']
295
+        #print(skaterAnimList)
296
+        if skaterAnimList:
297
+            name = skaterAnimList[objIndex-2]
298
+
299
+            skaterAnim = skaterAnimList[valueIndex-2]
300
+            name = name.replace(" ","")           
301
+            skaterAnim = str(skaterAnim)
302
+            skaterAnim = skaterAnim.replace(","," ") 
303
+            if skaterAnim == 'control_cube.002':
304
+                skaterAnim = skaterAnimList[valueIndex-3]
305
+                name = name.replace(" ","")           
306
+                skaterAnim = str(skaterAnim)
307
+                skaterAnim = skaterAnim.replace(","," ") 
308
+            #print(skaterAnim, (objIndex-2), (valueIndex-2)) 
309
+            #print(skaterAnimList)         
310
+            return(name, skaterAnim) 
311
+        
312
+    def returnSkaterAnimF(objIndex, valueIndex, own): 
313
+        skaterAnimFList =  own['skaterAnimFList']      
314
+        if skaterAnimFList:
315
+            name = skaterAnimFList[objIndex-2]
316
+            skaterAnimF = skaterAnimFList[valueIndex-2]
317
+            name = name.replace(" ","")
318
+            skaterAnimF = str(skaterAnimF)
319
+            skaterAnimF = skaterAnimF.replace(","," ")
320
+            #print('sOi', objIndex, 'sVi', valueIndex)
321
+            return(name, skaterAnimF)  
322
+        
323
+    def returnDeckAnim(objIndex, valueIndex, own): 
324
+        #print(objIndex-2)   
325
+        deckAnimList = own['deckAnimList']
326
+        if deckAnimList:
327
+            name = deckAnimList[objIndex-2]
328
+            deckAnim = deckAnimList[valueIndex-2]
329
+            name = name.replace(" ","")
330
+            deckAnim = str(deckAnim)
331
+            deckAnim = deckAnim.replace(","," ")
332
+            if deckAnim == 'control_cube.002':
333
+                deckAnim = deckAnimList[valueIndex-3]
334
+                name = name.replace(" ","")
335
+                deckAnim = str(deckAnim)
336
+                deckAnim = deckAnim.replace(","," ")
337
+            #print(deckAnim, (objIndex-2), (valueIndex-2))
338
+            #print('dOi', objIndex, 'dVi', valueIndex)            
339
+            return(name, deckAnim) 
340
+        
341
+    def returnDeckAnimF(objIndex, valueIndex, own):
342
+        deckAnimFList = own['deckAnimFList']
343
+        if deckAnimFList:
344
+            name = deckAnimFList[objIndex-2]
345
+            deckAnimF = deckAnimFList[valueIndex-2]
346
+            name = name.replace(" ","")
347
+            deckAnimF = str(deckAnimF)
348
+            deckAnimF = deckAnimF.replace(","," ")            
349
+            return(name, deckAnimF)
350
+###
351
+    def returnSrollVol(objIndex, valueIndex):
352
+        if srollVolList:
353
+            name = srollVolList[objIndex-2]
354
+            srollVol = srollVolList[valueIndex-2]
355
+            name = name.replace(" ","")
356
+            srollVol = str(srollVol)
357
+            srollVol = srollVol.replace(","," ")
358
+            srollVol = float(srollVol)
359
+            return(name, srollVol)
360
+        
361
+    def returnSrollPitch(objIndex, valueIndex):
362
+        if srollPitchList:
363
+            name = srollPitchList[objIndex-2]
364
+            srollPitch = srollPitchList[valueIndex-2]
365
+            name = name.replace(" ","")
366
+            srollPitch = str(srollPitch)
367
+            srollPitch = srollPitch.replace(","," ")
368
+            srollPitch = float(srollPitch)
369
+            return(name, srollPitch)                             ####
370
+###
371
+    def returnSgrind_cementVol(objIndex, valueIndex):
372
+        if sgrind_cementVolList:
373
+            name = sgrind_cementVolList[objIndex-2]
374
+            sgrind_cementVol = sgrind_cementVolList[valueIndex-2]
375
+            name = name.replace(" ","")
376
+            sgrind_cementVol = str(sgrind_cementVol)
377
+            sgrind_cementVol = sgrind_cementVol.replace(","," ")
378
+            sgrind_cementVol = float(sgrind_cementVol)
379
+            return(name, sgrind_cementVol)
380
+        
381
+    def returnSgrind_cementPitch(objIndex, valueIndex):
382
+        if sgrind_cementPitchList:
383
+            name = sgrind_cementPitchList[objIndex-2]
384
+            sgrind_cementPitch = sgrind_cementPitchList[valueIndex-2]
385
+            name = name.replace(" ","")
386
+            sgrind_cementPitch = str(sgrind_cementPitch)
387
+            sgrind_cementPitch = sgrind_cementPitch.replace(","," ")
388
+            sgrind_cementPitch = float(sgrind_cementPitch)
389
+            return(name, sgrind_cementPitch)                             ####              
390
+###
391
+    def returnSgrind_railVol(objIndex, valueIndex):
392
+        if sgrind_railVolList:
393
+            name = sgrind_railVolList[objIndex-2]
394
+            sgrind_railVol = sgrind_railVolList[valueIndex-2]
395
+            name = name.replace(" ","")
396
+            sgrind_railVol = str(sgrind_railVol)
397
+            sgrind_railVol = sgrind_railVol.replace(","," ")
398
+            sgrind_railVol = float(sgrind_railVol)
399
+            return(name, sgrind_railVol)
400
+        
401
+    def returnSgrind_railPitch(objIndex, valueIndex):
402
+        if sgrind_railPitchList:
403
+            name = sgrind_railPitchList[objIndex-2]
404
+            sgrind_railPitch = sgrind_railPitchList[valueIndex-2]
405
+            name = name.replace(" ","")
406
+            sgrind_railPitch = str(sgrind_railPitch)
407
+            sgrind_railPitch = sgrind_railPitch.replace(","," ")
408
+            sgrind_railPitch = float(sgrind_railPitch)
409
+            return(name, sgrind_railPitch)                             ####
410
+    def returnSpopsound(objIndex, valueIndex):
411
+        if spopsoundList:
412
+            name = spopsoundList[objIndex-2]
413
+            spopsound = spopsoundList[valueIndex-2]
414
+            name = name.replace(" ","")
415
+            spopsound = str(spopsound)
416
+            spopsound = spopsound.replace(","," ")
417
+            spopsound = int(spopsound)
418
+            return(name, spopsound)
419
+    def returnSlandsound(objIndex, valueIndex):
420
+        if slandsoundList:
421
+            name = slandsoundList[objIndex-2]
422
+            slandsound = slandsoundList[valueIndex-2]
423
+            name = name.replace(" ","")
424
+            slandsound = str(slandsound)
425
+            slandsound = slandsound.replace(","," ")
426
+            slandsound = int(slandsound)
427
+            return(name, slandsound) 
428
+    def returnSdeckvis(objIndex, valueIndex):
429
+        if sdeckvisList:
430
+            name = sdeckvisList[objIndex-2]
431
+            sdeckvis = sdeckvisList[valueIndex-2]
432
+            name = name.replace(" ","")
433
+            sdeckvis = str(sdeckvis)
434
+            sdeckvis = sdeckvis.replace(","," ")
435
+            sdeckvis = int(sdeckvis)
436
+            return(name, sdeckvis) 
437
+        
438
+    def returntdPosition(objIndex, valueIndex):
439
+        
440
+        if positiontdList:
441
+            name = positiontdList[objIndex-2]   #That -2 is a little workaround to a list index out of range error.
442
+            position = positiontdList[valueIndex-2]
443
+            name = name.replace(" ","")
444
+            position = str(position)
445
+            position = position.replace(","," ")
446
+            pX = float(position.split()[0])
447
+            pY = float(position.split()[1])
448
+            pZ = float(position.split()[2])
449
+            position = [pX,pY,pZ]
450
+            return(name, position)
451
+
452
+    def returntdOrientation(objIndex, valueIndex):
453
+        if orientationtdList:
454
+            name = orientationtdList[objIndex-2]
455
+            orientation = orientationtdList[valueIndex-2]
456
+            name = name.replace(" ","")
457
+            orientation = str(orientation)
458
+            orientation = orientation.replace(","," ")
459
+            orientation = orientation.split()
460
+            return(name, orientation)     
461
+        
462
+    def returnSrevertsound(objIndex, valueIndex):
463
+        if srevertsoundList:
464
+            name = srevertsoundList[objIndex-2]
465
+            srevertsound = srevertsoundList[valueIndex-2]
466
+            name = name.replace(" ","")
467
+            srevertsound = str(srevertsound)
468
+            srevertsound = srevertsound.replace(","," ")
469
+            srevertsound = int(srevertsound)
470
+            return(name, srevertsound)           
471
+                       
472
+###                
473
+
474
+    def getLengthPos(own):
475
+        positionList = own['positionList'] 
476
+        if positionList:
477
+            return(len(positionList))
478
+
479
+    def getLengthOri(own):
480
+        orientationList = own['orientationList']
481
+        if orientationList:
482
+            return(len(orientationList))
483
+
484
+    def getLengthSca():
485
+        if scaleList:
486
+            return(len(scaleList))
487
+
488
+    def getLengthCol():
489
+        if colorList:
490
+            return(len(colorList))
491
+    
492
+    def getLengthSta():
493
+        if stateList:
494
+            return(len(stateList))
495
+    
496
+    def getLengthVis():
497
+        if visibilityList:
498
+            return(len(visibilityList))
499
+    def getLengthSkaterAnim(own):
500
+        skaterAnimList = own['skaterAnimList']
501
+        if skaterAnimList:
502
+            return(len(skaterAnimList)) 
503
+    def getLengthSkaterAnimF(own):
504
+        skaterAnimFList = own['skaterAnimFList']
505
+        if skaterAnimFList:
506
+            return(len(skaterAnimFList)) 
507
+    def getLengthDeckAnim(own):
508
+        deckAnimList = own['deckAnimList']
509
+        if deckAnimList:
510
+            return(len(deckAnimList)) 
511
+    def getLengthDeckAnimF(own):
512
+        deckAnimFList = own['deckAnimFList']
513
+        if deckAnimFList:
514
+            #print(len(deckAnimFList), 'deckanimflisht')
515
+            return(len(deckAnimFList))
516
+    def getLengthSrollVol():
517
+        if srollVolList:
518
+            return(len(srollVolList)) 
519
+    def getLengthSrollPitch():
520
+        if srollPitchList:
521
+            return(len(srollPitchList)) 
522
+    def getLengthSgrind_cementVol():
523
+        if sgrind_cementVolList:
524
+            return(len(sgrind_cementVolList)) 
525
+    def getLengthSgrind_cementPitch():
526
+        if sgrind_cementPitchList:
527
+            return(len(sgrind_cementPitchList))
528
+    def getLengthSgrind_railVol():
529
+        if sgrind_railVolList:
530
+            return(len(sgrind_railVolList)) 
531
+    def getLengthSgrind_railPitch():
532
+        if sgrind_railPitchList:
533
+            return(len(sgrind_railPitchList))
534
+    def getLengthSpopsound():
535
+        if spopsoundList:
536
+            return(len(spopsoundList)) 
537
+    def getLengthSlandsound():
538
+        if slandsoundList:
539
+            return(len(slandsoundList)) 
540
+    def getLengthSdeckvis():
541
+        if sdeckvisList:
542
+            return(len(sdeckvisList))   
543
+    def getLengthtdPos():
544
+        if positiontdList:
545
+            return(len(positiontdList))
546
+    def getLengthtdOri():
547
+        if orientationtdList:
548
+            return(len(orientationtdList))
549
+    def getLengthSrevertsound():
550
+        if srevertsoundList:
551
+            return(len(srevertsoundList))    
552
+             
553
+                                                                                                    

+ 210
- 0
scripts/ai_manager.py View File

1
+def printplaying(skater,deck):
2
+    splaying_layers = "S: "
3
+    playing_layers = "D: "
4
+    tplaying_layers = "T: "
5
+    for x in range(9999):
6
+        if skater.isPlayingAction(x):
7
+        #if trucks.isPlayingAction(x):
8
+        #if skater.isPlayingAction(x):                        
9
+            splaying_layers += str(x)
10
+            splaying_layers += " "        
11
+        if deck.isPlayingAction(x):
12
+        #if trucks.isPlayingAction(x):
13
+        #if skater.isPlayingAction(x):                        
14
+            playing_layers += str(x)
15
+            playing_layers += " "
16
+          
17
+    print(splaying_layers, playing_layers)
18
+
19
+def main():
20
+
21
+    frame_rate = 60    #Set this to the framerate of your game.
22
+    optimization = 1    #An integer, must be at least 1! Higher value will make a smaller saved file size. I do not reccomend setting it to anything other than 1 though.
23
+    #recording_cutoff = 6974#7300 #3600   #Frames at which the oldest recorded frame will be deleted. 0 is no cutoff.
24
+    
25
+    recorder_state = 1   #This is the main state of the recorder object. State will be reverted to this value when the user breaks out of the playback.
26
+    allow_playback_break = True   #Allow the player to resume playing from the position in the recording.
27
+
28
+    from bge import logic
29
+    import aiRecord
30
+    import aiSortData
31
+    import npcChangeAnim
32
+    from mathutils import Vector
33
+    import math
34
+    
35
+    debugg = True
36
+
37
+    cont = logic.getCurrentController()
38
+    own = cont.owner
39
+    scene = logic.getCurrentScene()
40
+    dict = logic.globalDict
41
+    own['valueIndex'] = own['valueIndex'] + 2
42
+    #dict['recorder_on'] = recorder_on
43
+    npc_index = own['npc_index']
44
+    skater = dict['spawned_npcs'][npc_index]
45
+    recorder_on = dict.get('recorder_on')
46
+    own['recorder_on'] = recorder_on
47
+    #print("recorder on: ", recorder_on) 
48
+    own["playback"] = True
49
+    recording_cutoff = own['replay_length']
50
+    idle_timer = own['idle_timer']
51
+    npc_playback = own['npc_playback']
52
+    
53
+    
54
+    
55
+    if 'data_loaded' not in own:
56
+        #own['data_loaded'] = 1
57
+        aiRecord.loadData(cont, own)
58
+        if debugg: print('ai_loadData')
59
+        
60
+    if npc_playback == True:
61
+        cube = own
62
+        aiRecord.loadData(cont, own)   
63
+        #own['move'] = False          
64
+        #....................
65
+
66
+        valueIndex = own['valueIndex']
67
+        n = (valueIndex / recording_cutoff) * 1000
68
+        n = int(round(n))
69
+        #print(own['valueIndex'])
70
+        if own['objIndex'] < (recording_cutoff-3):
71
+            own['objIndex'] = own['objIndex'] + 2
72
+        else:
73
+            own['objIndex'] = 4   
74
+            print('replay end')    
75
+            npcChangeAnim.main(cont)
76
+            #own['npc_replay_name'] = '30secA.dat'
77
+            own['inited'] = False
78
+            own['rotate_in'] = True
79
+            own['move_to'] = True
80
+            own['rotate_out'] = True 
81
+            aiRecord.loadData(cont, own)
82
+    else:
83
+        if idle_timer < 5:
84
+            idle_timer += 1
85
+            #print('idling', idle_timer)
86
+        else:
87
+            idle_timer = 0
88
+            own['npc_rotate'] = True                 
89
+            
90
+    if own['move'] == True:
91
+        speed = .15
92
+        target = own['rpStartLoc']
93
+        my_vector = Vector([target[0], target[1], target[2]])
94
+        length = (own.worldPosition - my_vector).length
95
+        obj = own['target_object_name']
96
+        vect = own.getVectTo(obj)   
97
+        if length < .1:
98
+            own['move'] = False
99
+            obj = own['target_object_name']
100
+    own['idle_timer'] = idle_timer   
101
+    
102
+    try:
103
+        obj = own['target_object_name']
104
+        #print(obj.worldPosition)
105
+    except:
106
+        pass    
107
+    
108
+    
109
+    #11111111
110
+    if own['rotate_in'] == False and own['move_to'] == False and own['rotate_out'] == False:
111
+        own['npc_playback'] = True
112
+        #obj = own['target_object_name']
113
+        #obj.endObject()
114
+        #print('ending target')    
115
+    if own['rotate_in'] == True:
116
+        tActu = cont.actuators['npcTracking']
117
+        tActu.object = own['target_object_name']
118
+        try:
119
+            own['rotate_in_timer'] = own['rotate_in_timer'] + 1
120
+        except:
121
+            own['rotate_in_timer'] = 0
122
+        if own['rotate_in_timer'] < 120:    
123
+            cont.activate(tActu)
124
+            skater.playAction('reg_idle1', 0,120, layer=2, play_mode=1, speed=.5)  
125
+        else:
126
+            cont.deactivate(tActu) 
127
+            own['rotate_in'] = False
128
+            own['rotate_in_timer'] = 0
129
+            skater.stopAction(2)
130
+
131
+    elif own['move_to'] == True:
132
+        target = own['rpStartLoc']
133
+        #print(target, 'target', own.worldPosition, '++++++')
134
+        my_vector = Vector([target[0], target[1], target[2]])
135
+        length = (own.worldPosition - my_vector).length
136
+        sActu = cont.actuators['npcSteering']
137
+        sActu.target = own['target_object_name']
138
+        #length = round(length, 7)
139
+        if length > .1:
140
+            #print(length, 'length < .1')
141
+            #pass
142
+            cont.activate(sActu)
143
+            skater.playAction('reg_nwalk', 0,35, layer=2, play_mode=1, speed=.5)
144
+        else:
145
+            cont.deactivate(sActu)
146
+            own['move_to'] = False
147
+            print(length, 'length met')
148
+            skater.stopAction(2)
149
+
150
+    elif own['rotate_out'] == True:    
151
+        #own['rpStartZ'] = 180
152
+        #print(own['rpStartZ'], 'start')
153
+        xyz = own.localOrientation.to_euler()
154
+        #print(xyz[2], 'non euler')
155
+        rotz = math.degrees(xyz[2])
156
+        xyz[2] = xyz[2] + 1.57
157
+        rotz_b = rotz + 180
158
+        if rotz_b > 360:
159
+            rotz_b -= 360
160
+        srotz_b = own['rpStartZ'] + 180
161
+        if srotz_b > 360:
162
+            srotz_b -= 360
163
+        #print (rotz_b, srotz_b, '---rotations')        
164
+        #print (rotz, own['rpStartZ'], '---rotations')
165
+        num = rotz - (own['rpStartZ'])
166
+        amt = .03
167
+        amt2 = 1
168
+        
169
+        
170
+        local = own.worldOrientation.inverted() * ( own['target_object_name'].worldPosition - own.worldPosition) 
171
+
172
+        if local.x >0:
173
+            #target is in front
174
+            #print('in front')
175
+            pass
176
+        else:
177
+            #target is behind
178
+            #print('behind')
179
+            pass
180
+        if local.y > 0:
181
+                 #object on right
182
+            #print('on right')
183
+            rot = 'right'
184
+        else:
185
+                 #object is on left 
186
+            #print('on left')
187
+            rot = 'left'       
188
+        
189
+        
190
+        
191
+        skater.playAction('reg_idle1', 0,120, layer=2, play_mode=1, speed=.5)
192
+        if abs(num) < amt2:
193
+            own['npc_playback'] = True
194
+            own['npc_rotate'] = False
195
+            print('----starting replay', num)
196
+            own['rotate_out'] = False
197
+            obj = own['target_object_name']
198
+            obj.endObject()
199
+            print('ending target') 
200
+            skater.stopAction(2)            
201
+        #elif rotz > own['rpStartZ']:
202
+        elif rot == 'right':    
203
+            own.applyRotation([0,0,amt], True)
204
+            own.worldPosition = own['rpStartLoc']
205
+        #elif rotz < own['rpStartZ']:
206
+        elif rot == 'left':    
207
+            own.applyRotation([0,0,-amt], True) 
208
+            own.worldPosition = own['rpStartLoc']                
209
+    #print(own['rotate_in'], own['move_to'], own['rotate_out'])                          
210
+main()

+ 356
- 0
scripts/bike.py View File

1
+
2
+
3
+import bge
4
+from mathutils import Vector
5
+
6
+dict = bge.logic.globalDict
7
+scene = bge.logic.getCurrentScene()
8
+skater = scene.objects["Char4"]
9
+TURN_SENS = .04
10
+TURNAMT = .03
11
+AIR_TURMAMT = .07
12
+ACCEL_AMT = .06
13
+JUMP_AMT = 1300
14
+
15
+
16
+def turnL(own, gray):
17
+    if gray.positive:
18
+        own.applyRotation([0,0,TURNAMT], True)
19
+    else:            
20
+        own.applyRotation([0,0,AIR_TURMAMT], True)
21
+def turnR(own, gray):
22
+    if gray.positive:
23
+        own.applyRotation([0,0,-TURNAMT], True)
24
+    else:            
25
+        own.applyRotation([0,0,-AIR_TURMAMT], True)    
26
+def reset_timers(own, q1oncd, q2oncd, q3oncd, q4oncd, q5oncd, q6oncd, q7oncd, q8oncd):
27
+     q1oncd = 0
28
+     q2oncd = 0 
29
+     q3oncd = 0 
30
+     q4oncd = 0 
31
+     q5oncd = 0 
32
+     q6oncd = 0 
33
+     q7oncd = 0 
34
+     q8oncd = 0 
35
+     own["Q1oncd"] = 0
36
+     own["Q2oncd"] = 0
37
+     own["Q3oncd"] = 0
38
+     own["Q4oncd"] = 0
39
+     own["Q5oncd"] = 0
40
+     own["Q6oncd"] = 0
41
+     own["Q7oncd"] = 0
42
+     own["Q8oncd"] = 0
43
+
44
+
45
+def get_physics_action(cont, own):
46
+    #print(dict['lLR'])
47
+    action = 'None'
48
+    gray = cont.sensors['r_Ground']
49
+    
50
+    lLR = dict['lLR']
51
+    lUD = dict['lUD']
52
+    rLR = dict['rLR']
53
+    rUD = dict['rUD']
54
+    lTrig = dict['lTrig']
55
+    rTrig = dict['rTrig']
56
+    aBut = dict['aBut']
57
+    bBut = dict['bBut']
58
+    xBut = dict['xBut']
59
+    yBut = dict['yBut']
60
+    lBump = dict['lBump']
61
+    rBump = dict['rBump']
62
+    bkBut = dict['bkBut']
63
+    stBut = dict['stBut']
64
+    xbBut = dict['xbBut']
65
+    ltsBut = dict['ltsBut']
66
+    rtsBut = dict['rtsBut']
67
+    ldPad = dict['ldPad']
68
+    rdPad = dict['rdPad']
69
+    udPad = dict['udPad']
70
+    ddPad = dict['ddPad']    
71
+    
72
+    q1oncd = own["Q1oncd"]
73
+    q2oncd = own["Q2oncd"]
74
+    q3oncd = own["Q3oncd"]
75
+    q4oncd = own["Q4oncd"]
76
+    q5oncd = own["Q5oncd"]
77
+    q6oncd = own["Q6oncd"]
78
+    q7oncd = own["Q7oncd"]
79
+    q8oncd = own["Q8oncd"]
80
+    q1oncdl = own["Q1oncdl"]
81
+    q2oncdl = own["Q2oncdl"]
82
+    q3oncdl = own["Q3oncdl"]
83
+    q4oncdl = own["Q4oncdl"]
84
+    q5oncdl = own["Q5oncdl"]
85
+    q6oncdl = own["Q6oncdl"]
86
+    q7oncdl = own["Q7oncdl"]
87
+    q8oncdl = own["Q8oncdl"]
88
+
89
+    q1on = 0
90
+    q2on = 0
91
+    q3on = 0
92
+    q4on = 0
93
+    q5on = 0
94
+    q6on = 0
95
+    q7on = 0
96
+    q8on = 0
97
+    lq1on = 0
98
+    lq2on = 0
99
+    lq3on = 0
100
+    lq4on = 0
101
+    lq5on = 0
102
+    lq6on = 0
103
+    lq7on = 0
104
+    lq8on = 0
105
+    
106
+    countdown = 20    
107
+    
108
+    
109
+    ##################
110
+    ###realcontrols###
111
+    ##################
112
+    #       q1
113
+    #    q8    q2
114
+    # q7          q3
115
+    #    q6    q4
116
+    #       q5
117
+    ##################    
118
+    
119
+    if lUD > .04 and lLR < -0.04 :
120
+        lq6on = 1
121
+        q6oncdl = countdown
122
+        own["Q6oncdl"] = q6oncdl
123
+        #print("lq6on")
124
+    elif q6oncdl > 0:
125
+        lq6on = 0
126
+        q6oncdl = q6oncdl - 1
127
+        own["Q6oncdl"] = q6oncdl
128
+    #lq8
129
+    if lUD < -.04 and lLR < -0.04 :
130
+        lq8on = 1
131
+        q8oncdl = countdown
132
+        own["Q8oncdl"] = q8oncdl
133
+        #print("lq8on")
134
+    elif q8oncdl > 0:
135
+        lq8on = 0
136
+        q8oncdl = q8oncdl - 1
137
+        own["Q8oncdl"] = q8oncdl
138
+    #lq2
139
+    if lUD < -.04 and lLR > 0.04 :
140
+        lq2on = 1
141
+        q2oncdl = countdown
142
+        own["Q2oncdl"] = q2oncdl
143
+        #print("lq2on")
144
+    elif q2oncdl > 0:
145
+        lq2on = 0
146
+        q2oncdl = q2oncdl - 1
147
+        own["Q2oncdl"] = q2oncdl
148
+    #q4
149
+    if lUD > 0.04 and lLR > 0.04 :
150
+        lq4on = 1
151
+        q4oncdl = countdown
152
+        own["Q4oncdl"] = q4oncdl
153
+        #print("lq4on")
154
+    elif q4oncdl > 0:
155
+        lq4on = 0
156
+        q4oncdl = q4oncdl - 1
157
+        own["Q4oncdl"] = q4oncdl  
158
+    #q5
159
+    if lUD > .070 and lq4on == 0 and lq6on == 0:
160
+        lq5on = 1
161
+        q5oncdl = countdown
162
+        own["Q5oncdl"] = q5oncdl
163
+        #print("lq5on")
164
+    elif q5oncdl > 0:
165
+        lq5on = 0
166
+        q5oncdl = q5oncdl - 1
167
+        own["Q5oncdl"] = q5oncdl   
168
+    #q1    
169
+    if lUD < -0.070 and lq8on !=1 and lq2on != 1:
170
+        lq1on = 1
171
+        q1oncdl = countdown
172
+        own["Q1oncdl"] = q1oncdl
173
+        #print("lq1on")              
174
+    elif q1oncdl > 0:
175
+        lq1on = 0
176
+        q1oncdl = q1oncdl - 1
177
+        own["Q1oncdl"] = q1oncdl   
178
+    #q7
179
+    if lLR < -0.070 and lq8on != 1 and lq6on != 1:
180
+        lq7on = 1
181
+        q7oncdl = countdown
182
+        own["Q7oncdl"] = q7oncdl
183
+        #print("lq7on")       
184
+    elif q7oncdl > 0:
185
+        lq7on = 0
186
+        q7oncdl = q7oncdl - 1
187
+        own["Q7oncdl"] = q7oncdl  
188
+    #q3    
189
+    if lLR > 0.070 and lq2on !=1 and lq4on != 1:
190
+        lq3on = 1
191
+        q3oncdl = countdown
192
+        own["Q3oncdl"] = q3oncdl
193
+        #print("lq3on") 
194
+    elif q3oncdl > 0:
195
+        lq3on = 0
196
+        q3oncdl = q3oncdl - 1
197
+        own["Q3oncdl"] = q3oncdl       
198
+         
199
+    ################
200
+    #q6
201
+    if rUD > .04 and rLR < -0.04 :
202
+        q6on = 1
203
+        q6oncd = countdown
204
+        own["Q6oncd"] = q6oncd
205
+        #print("q6on")
206
+    elif q6oncd > 0:
207
+        q6on = 0
208
+        q6oncd = q6oncd - 1
209
+        own["Q6oncd"] = q6oncd
210
+        
211
+    #q8
212
+    if rUD < -.04 and rLR < -0.04 :
213
+        q8on = 1
214
+        q8oncd = countdown
215
+        own["Q8oncd"] = q8oncd
216
+        #print("q8on")
217
+    elif q8oncd > 0:
218
+        q8on = 0
219
+        q8oncd = q8oncd - 1
220
+        own["Q8oncd"] = q8oncd
221
+    #q2
222
+    if rUD < -.04 and rLR > 0.04 :
223
+        q2on = 1
224
+        q2oncd = countdown
225
+        own["Q2oncd"] = q2oncd
226
+        #print("q2on")
227
+    elif q2oncd > 0:
228
+        q2on = 0
229
+        q2oncd = q2oncd - 1
230
+        own["Q2oncd"] = q2oncd
231
+        
232
+    #q4
233
+    if rUD > 0.04 and rLR > 0.04 :
234
+        q4on = 1
235
+        q4oncd = countdown
236
+        own["Q4oncd"] = q4oncd
237
+        #print("q4on")
238
+    elif q4oncd > 0:
239
+        q4on = 0
240
+        q4oncd = q4oncd - 1
241
+        own["Q4oncd"] = q4oncd
242
+    #q5
243
+    if rUD > .070 or dict['kb_space'] == 2:
244
+        if q4on == 0 and q6on == 0:
245
+            q5on = 1
246
+            q5oncd = countdown
247
+            own["Q5oncd"] = q5oncd  
248
+    elif q5oncd > 0:
249
+        q5on = 0
250
+        q5oncd = q5oncd - 1
251
+        own["Q5oncd"] = q5oncd              
252
+
253
+    #q1    
254
+    if rUD < -0.070:
255
+        if q2on == 0 and q8on == 0:
256
+            #print("q1on")
257
+            q1on = 1
258
+            q1oncd = countdown
259
+            own["Q1oncd"] = q1oncd
260
+    elif q1oncd > 0:
261
+        q1on = 0
262
+        q1oncd = q1oncd - 1
263
+        own["Q1oncd"] = q1oncd            
264
+
265
+            
266
+      
267
+    #q7
268
+    if rLR < -0.070:
269
+        if q8on == 0 and q6on == 0:
270
+            q7on = 1
271
+            q7oncd = countdown
272
+            own["Q7oncd"] = q7oncd
273
+           
274
+    elif q7oncd > 0:
275
+        q7on = 0
276
+        q7oncd = q7oncd - 1
277
+        own["Q7oncd"] = q7oncd
278
+    #q3    
279
+    if rLR > 0.070:
280
+        if q4on == 0 and q2on == 0:
281
+            q3on = 1
282
+            q3oncd = countdown
283
+            own["Q3oncd"] = q3oncd
284
+    elif q3oncd > 0:
285
+        q3on = 0
286
+        q3oncd = q3oncd - 1
287
+        own["Q3oncd"] = q3oncd
288
+            
289
+     
290
+    
291
+    if dict['aBut'] == True:
292
+        action = 'forward'    
293
+    if dict['lLR'] > TURN_SENS:
294
+        action = 'turnR'
295
+        turnR(own, gray)
296
+    if dict['lLR'] < -TURN_SENS:
297
+        #action = 'turnL'    
298
+        turnL(own, gray)
299
+    if (q5oncd > 0 and q1oncd > 0 and q5oncd < q1oncd) or (q5oncd > 0 and q8oncd > 0 and q5oncd < q8oncd) or (q5oncd > 0 and q2oncd > 0 and q5oncd < q2oncd):
300
+        action = 'jump'
301
+        reset_timers(own, q1oncd, q2oncd, q3oncd, q4oncd, q5oncd, q6oncd, q7oncd, q8oncd)           
302
+
303
+
304
+    return action
305
+
306
+
307
+
308
+def do_physics_action(cont, own, action):
309
+#    if action == 'turnR':
310
+#        own.applyRotation([0,0,-TURNAMT], True)
311
+#    if action == 'turnL':
312
+#        own.applyRotation([0,0,TURNAMT], True)
313
+    if action == 'forward':
314
+        own.linearVelocity.x = own.linearVelocity.x - ACCEL_AMT
315
+    
316
+    if action == 'jump':
317
+        own.applyForce([0,0,JUMP_AMT], False)
318
+        print('jump')    
319
+    
320
+    gray = cont.sensors['r_Ground']
321
+    if gray.positive:
322
+        own.alignAxisToVect(Vector(gray.hitNormal)*1, 2, .25)
323
+    else:
324
+        own.alignAxisToVect(Vector([0,0,1]),2,.005)     
325
+    
326
+    
327
+    
328
+    if gray.positive:
329
+        own.linearVelocity.z = own.linearVelocity.z -.05    
330
+        own.linearVelocity.y = 0  
331
+def do_anims(cont, own):
332
+    
333
+    skater = scene.objects["Char4"]
334
+    skater.playAction("reg_bike.001", 20,20, layer=2, play_mode=1, speed=1)
335
+       
336
+        
337
+def main(cont):
338
+    own = cont.owner
339
+    try:
340
+        bike = scene.objects['player_bike']
341
+        #print('biking')
342
+        if dict['yBut'] == True and dict['last_yBut'] == False:
343
+            cont.activate(cont.actuators['walk'])
344
+            pbike = scene.addObject('prop_bike', own, 0)
345
+            pbike.localScale = [4.6, 4.6, 4.6]
346
+            pbike.localScale = [1, 1, 1] 
347
+            pbike.applyRotation([0,0,1.570796], False)
348
+            pbike.worldPosition.y = pbike.worldPosition.y - 1.       
349
+            bike.endObject()
350
+            skater.stopAction(9)
351
+        
352
+        action = get_physics_action(cont, own)
353
+        do_physics_action(cont, own, action)
354
+        do_anims(cont,own)
355
+    except:
356
+        pass    

+ 63
- 0
scripts/bpy_misc/pushpuller-addon.py View File

1
+import bpy
2
+ 
3
+class OBJECT_PT_pushpuller(bpy.types.Header):
4
+    bl_label = "Push Puller"
5
+    bl_space_type = "TEXT_EDITOR"
6
+    bl_region_type = "HEADER"
7
+    bl_context = "object"
8
+ 
9
+    def draw_header(self, context):
10
+        layout = self.layout
11
+        layout.label(text="", icon="PHYSICS")
12
+ 
13
+    def draw(self, context):
14
+        layout = self.layout
15
+        row = layout.row()
16
+        split = row.split(percentage=0.5)
17
+        col_left = split.column()
18
+        col_right = split.column()
19
+        col_right.operator("object.puller", text="Pull All")            
20
+        col_left.operator("object.pusher", text="Push All")
21
+        
22
+class OBJECT_OT_pusher(bpy.types.Operator):
23
+    bl_label = "Pusher"
24
+    bl_idname = "object.pusher"
25
+    bl_description = "Push text data block changes"
26
+ 
27
+    def execute(self, context):
28
+        area = bpy.context.area
29
+        for text in bpy.data.texts:
30
+            area.spaces[0].text = text
31
+            if text.filepath != '' and text.is_dirty:
32
+                bpy.ops.text.save() 
33
+                print("Saving: ", text.filepath)       
34
+        self.report({'INFO'}, "Performing push")
35
+        return {'FINISHED'}
36
+
37
+class OBJECT_OT_pullerer(bpy.types.Operator):
38
+    bl_label = "Puller"
39
+    bl_idname = "object.puller"
40
+    bl_description = "Pull text data block changes"
41
+ 
42
+    def execute(self, context):
43
+        area = bpy.context.area
44
+        self.report({'INFO'}, "Performing pull")
45
+        for text in bpy.data.texts:
46
+            area.spaces[0].text = text
47
+            if text.filepath != '':
48
+                try:
49
+                    bpy.ops.text.reload()
50
+                except:
51
+                    print("error reloading: ", text.filepath)    
52
+            if text.filepath != '' and text.is_dirty:
53
+                bpy.ops.text.save()
54
+        return {'FINISHED'}
55
+
56
+def register():
57
+    bpy.utils.register_module(__name__)
58
+ 
59
+def unregister():
60
+    bpy.utils.unregister_module(__name__)
61
+ 
62
+if __name__ == "__main__":
63
+    register()

+ 363
- 0
scripts/camera.py View File

1
+#zskcam
2
+import bge
3
+import mathutils
4
+from mathutils import *
5
+scene = bge.logic.getCurrentScene()
6
+cont = bge.logic.getCurrentController()
7
+own = cont.owner
8
+def main():
9
+    dict = bge.logic.globalDict 
10
+    camempty = scene.objects['camEmpty.001']
11
+    controlcube = scene.objects['control_cube.002']
12
+    
13
+    camCube = scene.objects['camCube']
14
+    
15
+    dropinCol = controlcube.sensors['dropinCol']
16
+    LAST_GRIND = controlcube['LAST_GRIND']
17
+    up = cont.sensors['up']
18
+    ray = cont.sensors['up']
19
+    down = cont.sensors['down']
20
+    left = cont.sensors['left']
21
+    right = cont.sensors['right']
22
+    distance = 0.12
23
+    cam = cont.actuators["Camera"]
24
+    near = cont.sensors["Near"]
25
+    move = own.actuators["move"]
26
+    #match camera actuaotor
27
+    cam_def_height = dict['cam_height'] #-.1 #-.6
28
+    #cam_def_min = 1.6
29
+    #cam_def_max = 2.4
30
+    cam_def_min = dict['cam_min']
31
+    cam_def_max = dict['cam_max']
32
+    cam_height = cam.height 
33
+    cam_min = cam.min   
34
+    cam_max = cam.max
35
+    lasty = controlcube['lasty']
36
+    cam_moved = 0
37
+    lastCamheight = controlcube['lastCamheight']
38
+    raised = 0
39
+    walk = controlcube['walk']
40
+    cam.axis = 4
41
+    ccheight = controlcube.worldPosition[2]
42
+    camwpz = own.worldPosition[2]
43
+    zdist = camwpz - ccheight
44
+    
45
+    cam1 = scene.objects['Camera.003']
46
+    cam2 = scene.objects['freecam']
47
+    cam3 = scene.objects['followcam']
48
+    
49
+    camList = scene.cameras
50
+    freecam = camList["freecam"]     
51
+    
52
+    if 'init' not in own:
53
+        own['init'] = 1
54
+        own['last_move_x'] = 0
55
+        own['last_move_y'] = 0
56
+        own['last_move_z'] = 0
57
+        own['last_rot_x'] = 0
58
+        own['last_rot_y'] = 0
59
+        own['last_rot_z'] = 0
60
+        own['idlecampos_x'] = 0
61
+        own['speed_mult'] = 1.00 
62
+        controlcube['driving'] = False  
63
+        dict['cur_ccH_min'] = dict['cam_walk_min']
64
+        dict['cur_ccH_max'] = dict['cam_walk_max']
65
+        cam.height = dict['cam_height']
66
+    acam = scene.active_camera
67
+
68
+
69
+    
70
+    #if 1 == 1:
71
+    #if own['playback'] == False:
72
+    if controlcube['driving'] == False:
73
+        if down.triggered == True and LAST_GRIND == False and walk == 0:
74
+            hitPosition = down.hitPosition
75
+            distance = own.getDistanceTo(hitPosition)
76
+            cam_moved = 1       
77
+            if distance < .2:
78
+                camempty['hitdown'] = True
79
+                cam.height = cam_height + .3
80
+                cam.damping = .0 
81
+                #print("raise cam")
82
+            if zdist < -.2:
83
+                cam.height = lastCamheight + .01
84
+                cam.damping = .0
85
+                raised = 1    
86
+            if (distance > .4 and distance < .6) and zdist > -.2 and raised == 0:
87
+                camheight2 = cam.height - .001
88
+                if cam.height < .2: 
89
+                    cam.height = camheight2
90
+                    #print("slow lower")
91
+            if distance >= .6 and zdist > -.2 and raised == 0:
92
+                cam.height = cam.height - .02
93
+                #print("slow lower2")           
94
+        if down.triggered == False and LAST_GRIND == False and cam_moved == 0 and walk == 0:
95
+            camempty['hitdown'] = False
96
+            if cam_height > (cam_def_height + .06) and zdist > -.2 and raised == 0:
97
+                cam.height = cam_height - .02
98
+        if cam_height < -.6 and cam_moved == 0 and LAST_GRIND == False and zdist > -.2 and raised == 0 and walk == 0:
99
+            cam_height = .1  
100
+        if LAST_GRIND == True and walk == 0:
101
+            if cam.height < -.5 or zdist < -.2:
102
+                cam.height = cam.height + .013
103
+            if cam.height >= -.5 and not down.triggered:
104
+                pass
105
+        
106
+        if walk == 1:
107
+            if dropinCol.positive == True and lasty == True:
108
+                pass 
109
+            else:
110
+                pass   
111
+        controlcube['lastCamheight'] = cam.height    
112
+        #########
113
+        #cam.min = dict['cam_min']
114
+        #cam.max = dict['cam_max']
115
+        cont.activate(own.actuators['Camera'])  
116
+        ########
117
+        
118
+        if near.triggered == True and walk == 0:
119
+            #print("near")
120
+            if cam.min < 1:
121
+                cam.min = cam.min + .1
122
+                cam.max = cam.max + .1
123
+            cam.height = cam_height + .01
124
+            cam.damping = .001
125
+            cont.activate(move)
126
+            
127
+        else:
128
+            #print("far")
129
+            cont.deactivate(move)
130
+            if cam.min > cam_def_min:
131
+                cam.min = cam.min - .05
132
+                cam.max = cam.max - .05 
133
+            cam.damping = .0          
134
+        if cam.damping != 0 and down.triggered == False and near.triggered == False:
135
+            cam.damping = 0.91             
136
+
137
+        obj = cont.owner
138
+        cube = controlcube
139
+        to = cube
140
+        from2 = obj
141
+        distance = 0.0
142
+        property = ""
143
+        face = 1
144
+        xray = 0
145
+        poly = 0
146
+        hit = obj.rayCast( to, from2, distance, property, face, xray, poly)
147
+        control = "control_cube.002"
148
+        hitobj = hit[0]
149
+        hitobj = str(hitobj)
150
+        if hitobj != control and walk == 0:
151
+            cam.damping = .0 
152
+            if cam.height < 3:
153
+                cam.height = cam_height + .1
154
+    
155
+    if dict['menu_idle_timer'] > 300:
156
+        move_len = 2048
157
+        if own['idlecampos_x'] < move_len:
158
+            own['idlecampos_x'] += 1
159
+        if own['idlecampos_x'] == move_len:
160
+           own['idlecampos_x'] = 0     
161
+            
162
+        if own['idlecampos_x'] < (move_len / 2):
163
+            move = [.0001, 0, 0]
164
+            freecam.applyMovement( move, True)
165
+            freecam.applyRotation([.0001, 0, .0001],True)
166
+        if own['idlecampos_x'] > (move_len / 2):
167
+            move = [-.0001, 0, 0]
168
+            freecam.applyMovement( move, True)
169
+            freecam.applyRotation([-.0001, 0, -.0001],True)        
170
+        
171
+    if dict['npause'] == True:
172
+        cont.deactivate(own.actuators['Camera'])
173
+        controlcube['camera'] = 2
174
+    if controlcube['camera'] == 2 and dict['joy_con'] == 1:
175
+        cont.deactivate(own.actuators['Camera'])
176
+        scene.active_camera = freecam 
177
+        cont.activate(cube.actuators['freecam']) 
178
+        #print('activating camera', freecam)  
179
+#####        
180
+    #get value 0-100    
181
+        lLR = dict['lLR'] / .082 * 100
182
+        lUD = dict['lUD'] / .082 * 100 - 20 / 80
183
+        rLR = dict['rLR'] / .082 * 100 - 20 / 80
184
+        rUD = dict['rUD'] / .082 * 100 - 20 / 80
185
+        lTrig = dict['lTrig'] / .082 * 100 - 20 / 80
186
+        rTrig = dict['rTrig'] / .082 * 100 - 20 / 80
187
+#        lBump = dict['lBump']
188
+#        rBump = dict['rBump']
189
+        
190
+        if lLR < -20:
191
+            lmLR = round((lLR + 20) / 80 * 100, 0) 
192
+        elif lLR > 20:
193
+            lmLR = round((lLR - 20) / 80 * 100, 0)
194
+        else: lmLR = 0  
195
+              
196
+        if lUD > 20:
197
+            lmUD = round((lUD - 20) / 80 * 100, 0)
198
+        elif lUD < -20:
199
+            lmUD = round((lUD + 20) / 80 * 100, 0)
200
+        else: lmUD = 0 
201
+
202
+        if rLR < -20:
203
+            rmLR = round((rLR + 20) / 80 * 100, 0)
204
+        elif rLR > 20:
205
+            rmLR = round((rLR - 20) / 80 * 100, 0)
206
+        else: rmLR = 0         
207
+        
208
+        if rUD > 20:
209
+            rmUD = round((rUD - 20) / 80 * 100, 0)
210
+        elif rUD < -20:
211
+            rmUD = round((rUD + 20) / 80 * 100, 0)
212
+        else: rmUD = 0 
213
+      
214
+        if lTrig > 3:
215
+            mTrig = lTrig * -1
216
+        elif rTrig > 3:
217
+            mTrig = rTrig    
218
+        else: mTrig = 0
219
+
220
+        #move camera
221
+        damping = .95
222
+        damping2 = 1.005
223
+        mult = .0005 * own['speed_mult']
224
+        move_x = lmUD * mult
225
+        move_y = lmLR * mult
226
+        move_z = (mTrig * -mult) / 2#4
227
+        
228
+        rot_mult = -.00015 * own['speed_mult']
229
+        rot_x = rmUD * rot_mult
230
+        rot_y = rmLR * rot_mult
231
+        
232
+        if move_x == 0 and own['last_move_x'] != 0:
233
+            move_x = own['last_move_x'] * damping
234
+        if move_y == 0 and own['last_move_y'] != 0:
235
+            move_y = own['last_move_y'] * damping 
236
+        if move_z == 0 and own['last_move_z'] != 0:
237
+            move_z = own['last_move_z'] * damping         
238
+        if rot_x == 0 and own['last_rot_x'] != 0:
239
+            rot_x = own['last_rot_x'] * damping
240
+        if rot_y == 0 and own['last_rot_y'] != 0:
241
+            rot_y = own['last_rot_y'] * damping         
242
+                             
243
+        move = [move_y, 0, move_x]
244
+        freecam.applyMovement( move, True)
245
+        freecam.applyMovement([0, 0, move_z], False)    
246
+        freecam.applyRotation([rot_x, 0, 0],True)
247
+        freecam.applyRotation([0, 0, rot_y],False)
248
+       
249
+        
250
+################    
251
+    #print(dict['walk'], 'walk')
252
+    multer = .02
253
+    if dict['walk'] == 1:
254
+        if dict['cur_ccH_targetHeight'] < dict['cam_walk_height']:
255
+            dist = dict['cam_walk_height'] - dict['cur_ccH_targetHeight']
256
+            
257
+            dict['cur_ccH_targetHeight'] = dict['cur_ccH_targetHeight'] + (dist * multer)
258
+            if dict['cur_ccH_targetHeight'] > dict['cam_walk_height']:
259
+                dict['cur_ccH_targetHeight'] = dict['cam_walk_height']
260
+                
261
+        cam.min = dict['cam_walk_min'] 
262
+        cam.max = dict['cam_walk_max']        
263
+        #ccH_targetHeight = .9
264
+    else:  
265
+
266
+        if dict['cur_ccH_targetHeight'] < dict['cch_targetHeight']:
267
+            dist = dict['cur_ccH_targetHeight'] - dict['cch_targetHeight']
268
+            dict['cur_ccH_targetHeight'] = dict['cur_ccH_targetHeight'] - (dist * multer)
269
+            if dict['cur_ccH_targetHeight'] > dict['cch_targetHeight'] - .001:
270
+                dict['cur_ccH_targetHeight'] = dict['cch_targetHeight']             
271
+
272
+        if dict['cur_ccH_targetHeight'] > dict['cch_targetHeight']:
273
+            dist = dict['cch_targetHeight'] - dict['cur_ccH_targetHeight'] 
274
+            dict['cur_ccH_targetHeight'] = dict['cur_ccH_targetHeight'] + (dist * multer)
275
+            if dict['cur_ccH_targetHeight'] < dict['cch_targetHeight'] + .001:
276
+                dict['cur_ccH_targetHeight'] = dict['cch_targetHeight']             
277
+        
278
+        
279
+    ccH_targetHeight = dict['cur_ccH_targetHeight']  
280
+    #print(dict['cur_ccH_targetHeight'])    
281
+    #dict['cur_ccH_targetHeight'] =            
282
+    #ccH_targetHeight = .3
283
+    ccH = camCube.worldPosition.z
284
+    pH = camCube.parent.worldPosition.z
285
+    ccheight = (round((ccH - pH), 2) - .4)
286
+    #print(ccheight, 'camera target height')
287
+    
288
+    localPos = camCube.localPosition.z
289
+    #print(localPos, 'local position')
290
+    if localPos != ccH_targetHeight:
291
+        num = ccH_targetHeight - localPos
292
+        camCube.localPosition.z += num
293
+    #if camHeightSet not in own:
294
+    if 1 == 1:    
295
+        num = ccH_targetHeight - ccheight
296
+    else:
297
+        own['camHeightSet'] = True    
298
+           
299
+    if dict['npause'] == False:
300
+        cont.activate(own.actuators['Camera']) 
301
+        controlcube['camera'] = 0    
302
+    
303
+    cur_lens = cam1.lens
304
+    cur_min = cam.min
305
+    cur_max = cam.max
306
+    #print(cur_lens)
307
+    inc = .025
308
+    if walk == 1:
309
+        #lens
310
+        if dict['walk_focal_length'] > cur_lens:
311
+            new_lens = cur_lens + inc
312
+        else:
313
+            new_lens = cur_lens - inc
314
+        if cur_lens  > (dict['walk_focal_length'] - .1) and cur_lens  < (dict['walk_focal_length'] + .1):
315
+            new_lens = dict['walk_focal_length']  
316
+            
317
+        #distance      
318
+        inc = .025   
319
+        if cur_min > (dict['cam_walk_min'] - inc):
320
+            new_min = cur_min - inc
321
+        if cur_min < (dict['cam_walk_min'] + inc):
322
+            new_min = cur_min + inc 
323
+        if cur_max > (dict['cam_walk_max'] - inc):
324
+            new_max = cur_min - inc
325
+        if cur_max < (dict['cam_walk_max'] + inc):
326
+            new_max = cur_min + inc           
327
+    else:
328
+        #lens
329
+        if dict['focal_length'] > cur_lens:
330
+            new_lens = cur_lens + inc
331
+        else:
332
+            new_lens = cur_lens - inc 
333
+        if cur_lens  > (dict['focal_length'] - .1) and cur_lens  < (dict['focal_length'] + .1):
334
+            new_lens = dict['focal_length'] 
335
+            
336
+        #distance  
337
+        inc = .025   
338
+        if cur_min > (dict['cam_min'] - inc):
339
+            new_min = cur_min - inc
340
+        if cur_min < (dict['cam_min'] + inc):
341
+            new_min = cur_min + inc 
342
+        if cur_max > (dict['cam_max'] - inc):
343
+            new_max = cur_min - inc
344
+        if cur_max < (dict['cam_max'] + inc):
345
+            new_max = cur_min + inc        
346
+            
347
+        
348
+            
349
+                                         
350
+        
351
+    focallength = new_lens
352
+    cam1.lens = focallength
353
+    cam2.lens = focallength
354
+    cam3.lens = focallength
355
+    try:
356
+        cam.min = new_min
357
+        cam.max = new_max  
358
+        #print(new_min, new_max)     
359
+    except:
360
+        pass    
361
+    
362
+                    
363
+main()

+ 880
- 0
scripts/car.py View File

1
+"""
2
+
3
+CarSetup 
4
+
5
+
6
+"""
7
+
8
+#import blender game engine content
9
+from bge import logic, constraints
10
+
11
+#import other modules
12
+import math, mathutils
13
+
14
+
15
+os = 'Windows'
16
+from sys import platform
17
+if platform != "win32":
18
+ os = 'Linux'
19
+def onWindows():
20
+ return os == 'Windows'
21
+import bge
22
+import GameLogic
23
+import ctypes
24
+
25
+dict = bge.logic.globalDict 
26
+
27
+
28
+reduction = 400000
29
+axisTh = 0.03 
30
+
31
+cont = GameLogic.getCurrentController() 
32
+obj = bge.logic.getCurrentScene().objects
33
+own = cont.owner
34
+
35
+class CarSetup:
36
+    
37
+    def __init__(self):
38
+        
39
+        #list of cars
40
+        self.carList = {}
41
+        
42
+        #list of tires
43
+        self.tires = {}
44
+        
45
+        #car turn amount
46
+        self.turnAmount = {}
47
+    
48
+    
49
+    def carInitialized(self, car):
50
+        
51
+        #check for initialized property
52
+        if "initialized" in car:
53
+            
54
+            #check if car is initialized
55
+            if car["initialized"] == True:
56
+                
57
+                #car is initialized
58
+                return True
59
+        
60
+        #car is not initialized
61
+        return False
62
+    
63
+    
64
+    def carConstraint(self, car):
65
+        
66
+        #get physics ID
67
+        carPhysicsID = car.getPhysicsId()
68
+         
69
+        #create a vehicle constraint 
70
+        vehicleConstraint = constraints.createConstraint(carPhysicsID, 0, 11)
71
+         
72
+        #get the constraint ID
73
+        constraintID = vehicleConstraint.getConstraintId()
74
+          
75
+        #get the vehicle constraint ID
76
+        vehicleID =  constraints.getVehicleConstraint(constraintID)
77
+    
78
+        #save vehicle constraint ID as an object variable
79
+        car["vehicleID"] = vehicleID
80
+        
81
+        #return vehicle ID
82
+        return vehicleID
83
+    
84
+    
85
+    def positionTires(self, car):
86
+        
87
+        #get the list of tires
88
+        tireList = self.tires[car]
89
+        
90
+        tire1 = tireList["TireFD"]  #tire front drivers
91
+        tire2 = tireList["TireFP"]  #tire front passengers
92
+        tire3 = tireList["TireRD"]  #tire rear drivers
93
+        tire4 = tireList["TireRP"]  #tire rear passnengers
94
+        
95
+        tire1Pos = tire1.worldPosition  #tire front drivers
96
+        tire2Pos = tire2.worldPosition  #tire front passengers
97
+        tire3Pos = tire3.worldPosition  #tire rear drivers
98
+        tire4Pos = tire4.worldPosition  #tire rear passnengers
99
+        
100
+        #car position
101
+        carPos = car.worldPosition
102
+        
103
+        #tire front drivers
104
+        tire1Pos = [tire1Pos[0] - carPos[0],
105
+                    tire1Pos[1] - carPos[1],
106
+                    tire1Pos[2] - carPos[2]]
107
+        
108
+        #tire front passengers
109
+        tire2Pos = [tire2Pos[0] - carPos[0],
110
+                    tire2Pos[1] - carPos[1],
111
+                    tire2Pos[2] - carPos[2]]
112
+        
113
+        #tire rear drivers
114
+        tire3Pos = [tire3Pos[0] - carPos[0],
115
+                    tire3Pos[1] - carPos[1],
116
+                    tire3Pos[2] - carPos[2]]
117
+        
118
+        #tire rear passengers
119
+        tire4Pos = [tire4Pos[0] - carPos[0],
120
+                    tire4Pos[1] - carPos[1],
121
+                    tire4Pos[2] - carPos[2]]
122
+            
123
+        return (tire1Pos, tire2Pos, tire3Pos, tire4Pos)
124
+    
125
+    
126
+    def tireRadius(self, car):
127
+        
128
+        #get the list of tires
129
+        tireList = self.tires[car]
130
+        
131
+        tire1Radius = tireList["TireFD"].localScale[2]/2    #tire front drivers
132
+        tire2Radius = tireList["TireFP"].localScale[2]/2    #tire front passengers
133
+        tire3Radius = tireList["TireRD"].localScale[2]/2    #tire rear drivers
134
+        tire4Radius = tireList["TireRP"].localScale[2]/2    #tire rear passengers
135
+        
136
+        #check for radius override
137
+        if "Radius" in tireList["TireFD"]:
138
+            tire1Radius = tireList["TireFD"]["Radius"]
139
+            
140
+        if "Radius" in tireList["TireFP"]:
141
+            tire2Radius = tireList["TireFP"]["Radius"]
142
+            
143
+        if "Radius" in tireList["TireRD"]:
144
+            tire3Radius = tireList["TireRD"]["Radius"]
145
+            
146
+        if "Radius" in tireList["TireRP"]:
147
+            tire4Radius = tireList["TireRP"]["Radius"]
148
+        
149
+        #return (tire1Radius, tire2Radius, tire3Radius, tire4Radius)
150
+        return (.2, .2, .2, .2)
151
+    
152
+    
153
+    def suspensionHeight(self, car):
154
+        
155
+        tireList = self.tires[car]
156
+        
157
+        tire1height = 0.2   #tire front drivers
158
+        tire2height = 0.2   #tire front passengers
159
+        tire3height = 0.2   #tire rear drivers
160
+        tire4height = 0.2   #tire rear passengers
161
+        
162
+        #check for suspension height override
163
+        if "Height" in tireList["TireFD"]:
164
+            tire1height = tireList["TireFD"]["Height"]
165
+            
166
+        if "Height" in tireList["TireFP"]:
167
+            tire2height = tireList["TireFP"]["Height"]
168
+            
169
+        if "Height" in tireList["TireRD"]:
170
+            tire3height = tireList["TireRD"]["Height"]
171
+            
172
+        if "Height" in tireList["TireRP"]:
173
+            tire4height = tireList["TireRP"]["Height"]
174
+        
175
+        return (tire1height, tire2height, tire3height, tire4height)
176
+    
177
+    
178
+    def suspensionAngle(self):
179
+        
180
+        tire1Angle = [0, 0, -1] #tire front drivers
181
+        tire2Angle = [0, 0, -1] #tire front passengers
182
+        tire3Angle = [0, 0, -1] #tire rear drivers
183
+        tire4Angle = [0, 0, -1] #tire rear passengers
184
+        
185
+        return (tire1Angle, tire2Angle, tire3Angle, tire4Angle)
186
+    
187
+    
188
+    def tireAxis(self):
189
+        
190
+        tire1Axis = [-1, 0, 0]  #tire front drivers
191
+        tire2Axis = [-1, 0, 0]  #tire front passengers
192
+        tire3Axis = [-1, 0, 0]  #tire rear drivers
193
+        tire4Axis = [-1, 0, 0]  #tire rear passengers
194
+        
195
+        return (tire1Axis, tire2Axis, tire3Axis, tire4Axis)
196
+    
197
+    
198
+    def tireSteering(self):
199
+        
200
+        tire1Steer = True   #tire front drivers
201
+        tire2Steer = True   #tire front passengers
202
+        tire3Steer = False  #tire rear drivers
203
+        tire4Steer = False  #tire rear passengers
204
+        
205
+        return (tire1Steer, tire2Steer, tire3Steer, tire4Steer)
206
+    
207
+    
208
+    def addTires(self, car, vehicleID):
209
+        
210
+        #get the list of tires
211
+        tireList = self.tires[car]
212
+        
213
+        #list the tires
214
+        tires = [tireList["TireFD"],
215
+                 tireList["TireFP"],
216
+                 tireList["TireRD"],
217
+                 tireList["TireRP"]]
218
+        
219
+        #position the tires
220
+        tirePos = self.positionTires(car)
221
+        
222
+        #calculate tire radius
223
+        tireRadius = self.tireRadius(car)
224
+        
225
+        #get the suspension heght
226
+        suspensionHeight = self.suspensionHeight(car)
227
+        
228
+        #get the suspension angle
229
+        suspensionAngle = self.suspensionAngle()
230
+        
231
+        #get the tire axis
232
+        tireAxis = self.tireAxis()
233
+        
234
+        #get which wheels turn
235
+        tireSteer = self.tireSteering()
236
+        
237
+        for tire in range(0, 4):
238
+            
239
+            #tire object
240
+            obj = tires[tire]
241
+            
242
+            #tire position
243
+            pos = tirePos[tire]
244
+            
245
+            #tire suspension height
246
+            suspenHeight = suspensionHeight[tire]
247
+            
248
+            #angle of suspension
249
+            suspenAngle = suspensionAngle[tire]
250
+            
251
+            #tire rotation axis
252
+            axis = tireAxis[tire]
253
+            
254
+            #tire radius
255
+            radius = tireRadius[tire]
256
+            
257
+            #tire steering
258
+            steering = tireSteer[tire]
259
+            
260
+            #add wheel to car
261
+            vehicleID.addWheel(obj, pos, suspenAngle, axis, suspenHeight, radius, steering)
262
+            
263
+    
264
+    def tireGrip(self, car, vehicleID):
265
+        
266
+        #list of tires
267
+        tireList = self.tires[car]
268
+        #10
269
+        tire1Grip = 8  #tire front drivers
270
+        tire2Grip = 8  #tire front Passengers
271
+        tire3Grip = 8  #tire rear drivers
272
+        tire4Grip = 8  #tire rear passengers
273
+        
274
+        #check for grip override
275
+        if "Grip" in tireList["TireFD"]:
276
+            tire1Grip = tireList["TireFD"]["Grip"]
277
+            
278
+        if "Grip" in tireList["TireFP"]:
279
+            tire2Grip = tireList["TireFP"]["Grip"]
280
+            
281
+        if "Grip" in tireList["TireRD"]:
282
+            tire3Grip = tireList["TireRD"]["Grip"]
283
+            
284
+        if "Grip" in tireList["TireRP"]:
285
+            tire4Grip = tireList["TireRP"]["Grip"]
286
+        
287
+        vehicleID.setTyreFriction(tire1Grip, 0) #tire front drivers
288
+        vehicleID.setTyreFriction(tire2Grip, 1) #tire front Passengers
289
+        vehicleID.setTyreFriction(tire3Grip, 2) #tire rear drivers
290
+        vehicleID.setTyreFriction(tire4Grip, 3) #tire rear passengers
291
+        
292
+    
293
+    def suspensionCompression(self, car, vehicleID):
294
+        
295
+        #list of tires
296
+        tireList = self.tires[car]
297
+        #6
298
+        tire1Compress = 6   #tire front drivers
299
+        tire2Compress = 6   #tire front Passengers
300
+        tire3Compress = 6   #tire rear drivers
301
+        tire4Compress = 6   #tire rear passengers
302
+        
303
+        #check for compression override
304
+        if "Compression" in tireList["TireFD"]:
305
+            tire1Compress = tireList["TireFD"]["Compression"]
306
+            
307
+        if "Compression" in tireList["TireFP"]:
308
+            tire2Compress = tireList["TireFP"]["Compression"]
309
+            
310
+        if "Compression" in tireList["TireRD"]:
311
+            tire3Compress = tireList["TireRD"]["Compression"]
312
+            
313
+        if "Compression" in tireList["TireRP"]:
314
+            tire4Compress = tireList["TireRP"]["Compression"]
315
+        
316
+        vehicleID.setSuspensionCompression(tire1Compress, 0)    #tire front drivers
317
+        vehicleID.setSuspensionCompression(tire2Compress, 1)    #tire front Passengers
318
+        vehicleID.setSuspensionCompression(tire3Compress, 2)    #tire rear drivers
319
+        vehicleID.setSuspensionCompression(tire4Compress, 3)    #tire rear passengers
320
+    
321
+    
322
+    def suspensionDamping(self, car, vehicleID):
323
+        
324
+        #list of tires
325
+        tireList = self.tires[car]
326
+        
327
+        tire1Damp = 5   #tire front drivers
328
+        tire2Damp = 5   #tire front Passengers
329
+        tire3Damp = 5   #tire rear drivers
330
+        tire4Damp = 5   #tire rear passengers
331
+        
332
+        #check for damping override
333
+        if "Damping" in tireList["TireFD"]:
334
+            tire1Damp = tireList["TireFD"]["Damping"]
335
+            
336
+        if "Damping" in tireList["TireFP"]:
337
+            tire2Damp = tireList["TireFP"]["Damping"]
338
+            
339
+        if "Damping" in tireList["TireRD"]:
340
+            tire3Damp = tireList["TireRD"]["Damping"]
341
+            
342
+        if "Damping" in tireList["TireRP"]:
343
+            tire4Damp = tireList["TireRP"]["Damping"]
344
+        
345
+        vehicleID.setSuspensionDamping(tire1Damp, 0)    #tire front drivers
346
+        vehicleID.setSuspensionDamping(tire2Damp, 1)    #tire front Passengers
347
+        vehicleID.setSuspensionDamping(tire3Damp, 2)    #tire rear drivers
348
+        vehicleID.setSuspensionDamping(tire4Damp, 3)    #tire rear passengers
349
+    
350
+    
351
+    def suspensionStiffness(self, car, vehicleID):
352
+        
353
+        #list of tires
354
+        tireList = self.tires[car]
355
+        
356
+        tire1Stiffness = 12.5       #tire front drivers
357
+        tire2Stiffness = 12.5       #tire front Passengers
358
+        tire3Stiffness = 12.5       #tire rear drivers
359
+        tire4Stiffness = 12.5       #tire rear passengers
360
+        
361
+        #check for stiffness override
362
+        if "Stiffness" in tireList["TireFD"]:
363
+            tire1Stiffness = tireList["TireFD"]["Stiffness"]
364
+            
365
+        if "Stiffness" in tireList["TireFP"]:
366
+            tire2Stiffness = tireList["TireFP"]["Stiffness"]
367
+            
368
+        if "Stiffness" in tireList["TireRD"]:
369
+            tire3Stiffness = tireList["TireRD"]["Stiffness"]
370
+            
371
+        if "Stiffness" in tireList["TireRP"]:
372
+            tire4Stiffness = tireList["TireRP"]["Stiffness"]
373
+        
374
+        vehicleID.setSuspensionStiffness(tire1Stiffness, 0) #tire front drivers
375
+        vehicleID.setSuspensionStiffness(tire2Stiffness, 1) #tire front Passengers
376
+        vehicleID.setSuspensionStiffness(tire3Stiffness, 2) #tire rear drivers
377
+        vehicleID.setSuspensionStiffness(tire4Stiffness, 3) #tire rear passengers
378
+    
379
+    
380
+    def suspensionRollInfluence(self, car, vehicleID):
381
+        
382
+        #list of tires
383
+        tireList = self.tires[car]
384
+        
385
+        tire1Roll = -0.16   #tire front drivers
386
+        tire2Roll = -0.16   #tire front Passengers
387
+        tire3Roll = -0.16   #tire rear drivers
388
+        tire4Roll = -0.16   #tire rear passengers
389
+        
390
+        #check for roll influence override
391
+        if "RollInfluence" in tireList["TireFD"]:
392
+            tire1Roll = -tireList["TireFD"]["RollInfluence"]
393
+            
394
+        if "Roll" in tireList["TireFP"]:
395
+            tire2Roll = -tireList["TireFP"]["RollInfluence"]
396
+            
397
+        if "Roll" in tireList["TireRD"]:
398
+            tire3Roll = -tireList["TireRD"]["RollInfluence"]
399
+            
400
+        if "Roll" in tireList["TireRP"]:
401
+            tire4Roll = -tireList["TireRP"]["RollInfluence"]
402
+        
403
+        vehicleID.setRollInfluence(tire1Roll, 0)    #tire front drivers
404
+        vehicleID.setRollInfluence(tire2Roll, 1)    #tire front Passengers
405
+        vehicleID.setRollInfluence(tire3Roll, 2)    #tire rear drivers
406
+        vehicleID.setRollInfluence(tire4Roll, 3)    #tire rear passengers
407
+    
408
+    
409
+#create CarSetup object
410
+carsetup = CarSetup()
411
+
412
+
413
+def _initialize(controller):
414
+    
415
+    #get the car object
416
+    car = controller.owner
417
+    
418
+    #get current orientation
419
+    carOrient = car.worldOrientation
420
+    
421
+    #convert orientation to euler
422
+    carEuler = carOrient.to_euler()
423
+    newCarEuler = carOrient.to_euler()
424
+    
425
+    #set euler rotation
426
+    newCarEuler[0] = 0
427
+    newCarEuler[1] = 0
428
+    newCarEuler[2] = 0
429
+    
430
+    #set car orientation
431
+    car.worldOrientation = newCarEuler.to_matrix()
432
+    
433
+    if not car.name in carsetup.carList:
434
+        
435
+        #assign the car
436
+        carsetup.carList[car] = car
437
+        
438
+        tires = {}
439
+        
440
+        #look for tires
441
+        for c in car.children:
442
+            
443
+            tire = "Tire"
444
+            
445
+            #check if tire object
446
+            if "Tire" in c:
447
+                
448
+                #build the tire name
449
+                tire += c["Tire"]
450
+                
451
+                #add tire to list
452
+                tires[tire] = c
453
+                
454
+                #assign tires owner
455
+                c["owner"] = car.name
456
+                
457
+                #clear tire parent
458
+                c.removeParent()
459
+        
460
+        #add tires to list of tires
461
+        carsetup.tires[car] = tires
462
+        
463
+        #build the car constraint
464
+        vehicleID = carsetup.carConstraint(car)
465
+        
466
+        #add tires to car
467
+        carsetup.addTires(car, vehicleID)
468
+        
469
+        #set tire grip
470
+        carsetup.tireGrip(car, vehicleID)
471
+        
472
+        #set suspension compression
473
+        carsetup.suspensionCompression(car, vehicleID)
474
+        
475
+        #set suspension damping
476
+        carsetup.suspensionDamping(car, vehicleID)
477
+        
478
+        #set suspension stiffness
479
+        carsetup.suspensionStiffness(car, vehicleID)
480
+        
481
+        #set suspension roll influence
482
+        carsetup.suspensionRollInfluence(car, vehicleID)
483
+    
484
+    #set car orientation
485
+    car.worldOrientation = carEuler.to_matrix()
486
+    
487
+    #set car to initialized
488
+    car["initialized"] = True
489
+    
490
+    #set turn amount
491
+    carsetup.turnAmount[car] = 0
492
+    
493
+    #check for "TurnAmount" property in car
494
+    if not "TurnAmount" in car:
495
+        
496
+        #set default turn amount
497
+        car["TurnAmount"] = 50#35
498
+        
499
+    #check for "TurnSpeed" property in car
500
+    if not "TurnSpeed" in car:
501
+        
502
+        #set default turn speed
503
+        car["TurnSpeed"] = 1
504
+        car["TurnSpeed2"] = 20#2
505
+
506
+
507
+
508
+def _constraintID(car):
509
+        
510
+    # get saved vehicle Constraint ID
511
+    vehicleID = car["vehicleID"]
512
+    
513
+    return vehicleID
514
+
515
+
516
+def _powertrain(controller, car):
517
+    
518
+    #declare variables
519
+    gas = None
520
+    reverse = None
521
+    brake = None
522
+    ebrake = None
523
+    
524
+    #get the vehicl id
525
+    vehicleID = _constraintID(car)
526
+    
527
+    #engine power
528
+    power = 0
529
+    
530
+    #engine
531
+    engine = True
532
+    
533
+    #check for engine override
534
+    if "Engine" in car:
535
+        engine = car["Engine"]
536
+    
537
+    
538
+    
539
+    #set default values
540
+    forwardSpeed = 70
541
+    
542
+    reverseSpeed = 200
543
+    brakeAmount = 10
544
+    eBrakeAmount = 40
545
+    backdrive = True
546
+    frontdrive = False
547
+    
548
+    #check for forward speed override
549
+    if "ForwardSpeed" in car:
550
+        
551
+        #set forward speed
552
+        forwardSpeed = car["ForwardSpeed"]
553
+    
554
+    #check for reverse speed override
555
+    if "ReverseSpeed" in car:
556
+        
557
+        #set reverse speed
558
+        reverseSpeed = car["ReverseSpeed"]
559
+    
560
+    #check for brake amount override
561
+    if "BrakeAmount" in car:
562
+        
563
+        #set brake amount
564
+        brakeAmount = car["BrakeAmount"]
565
+    
566
+    #check for E-brake amount override
567
+    if "EBrakeAmount" in car:
568
+        
569
+        #set brake amount
570
+        eBrakeAmount = car["EBrakeAmount"]
571
+    
572
+    #check for BackWheelDrive override
573
+    if "BackWheelDrive" in car:
574
+        
575
+        #set back wheel drive
576
+        backdrive = car["BackWheelDrive"]
577
+    
578
+    #check for FrontWheelDrive override
579
+    if "FrontWheelDrive" in car:
580
+        
581
+        #set front wheel drive
582
+        frontdrive = car["FrontWheelDrive"]
583
+    
584
+    #check for gas sensor
585
+    if "Gas" in controller.sensors:
586
+        #gas = controller.sensors["Gas"]       
587
+        gas = own['gas']
588
+    #check for reverse sensor
589
+    #if "Reverse" in controller.sensors:
590
+        #reverse = controller.sensors["Reverse"]
591
+    reverse = own['reverse']
592
+    #check for brake sensor
593
+    #if "Brake" in controller.sensors:
594
+        #brake = controller.sensors["Brake"]
595
+    brake = own['brake']
596
+    #check for E-brake sensor
597
+    if "EBrake" in controller.sensors:
598
+        ebrake = controller.sensors["EBrake"]
599
+    
600
+    #check if gas exists
601
+    if gas:
602
+        
603
+        #check if gas is positive
604
+        if gas == 1:
605
+            
606
+            #check if engine is on
607
+            if engine:
608
+                #set power
609
+                power = -forwardSpeed
610
+    
611
+    #check if reverse exists
612
+    #if reverse:
613
+        
614
+    #check if reverse is positive
615
+    if reverse == 1:
616
+        
617
+        #check if engine is on
618
+        if engine:
619
+            
620
+            #set power
621
+            power = reverseSpeed
622
+            
623
+            #check if gas exists
624
+            if gas:
625
+                
626
+                #check if gas is positive
627
+                if gas == 1:
628
+                    
629
+                    #set power
630
+                    power = 0
631
+    
632
+    #check if brake exists
633
+    #if brake:
634
+        
635
+    #check if brake is positive
636
+    if brake == 1:
637
+        
638
+        #apply braking
639
+        vehicleID.applyBraking(brakeAmount, 2)
640
+        vehicleID.applyBraking(brakeAmount, 3)
641
+        
642
+        #set power
643
+        power = 0
644
+        
645
+    else:
646
+        #remove braking
647
+        vehicleID.applyBraking(0, 2)
648
+        vehicleID.applyBraking(0, 3)
649
+        
650
+    #check if e brake exists
651
+    if ebrake:
652
+        
653
+        #check if e brake is positive
654
+        if ebrake.positive:
655
+            
656
+            #apply braking
657
+            vehicleID.applyBraking(eBrakeAmount, 2)
658
+            vehicleID.applyBraking(eBrakeAmount, 3)
659
+            
660
+            #set power
661
+            power = 0
662
+    
663
+            
664
+    #check if back wheel drive
665
+    if backdrive:
666
+        
667
+        #apply power
668
+        vehicleID.applyEngineForce(-power, 2)
669
+        vehicleID.applyEngineForce(-power, 3)
670
+        
671
+    #check if front wheel drive
672
+    if frontdrive:
673
+        
674
+        #apply power
675
+        vehicleID.applyEngineForce(-power, 0)
676
+        vehicleID.applyEngineForce(-power, 1)
677
+
678
+
679
+def _steer(controller, car):
680
+    
681
+    #declare variables
682
+    #left = None
683
+    #right = None
684
+    left = own['left']
685
+    right = own['right']
686
+    #turn amount
687
+    turnAmount = math.radians(car["TurnAmount"])
688
+    
689
+    #get turn speed
690
+    turnSpeed = car["TurnSpeed"] * 0.01
691
+    turnSpeed2 = car["TurnSpeed2"] * 0.01
692
+    
693
+    #get vehicle id
694
+    vehicleID = _constraintID(car)
695
+    
696
+    #check for left sensor
697
+    #if "Left" in controller.sensors:
698
+        #left = controller.sensors["Left"]
699
+        
700
+    #check for right sensor
701
+    #if "Right" in controller.sensors:
702
+        #right = controller.sensors["Right"]
703
+    
704
+    #check if the sensors exist
705
+    #if left and right:
706
+        
707
+        #check if both are positive
708
+        #if left.positive and right.positive:
709
+            
710
+            #pass
711
+        
712
+        #check if left is positive
713
+        #elif left.positive and not right.positive:
714
+    if left == True:    
715
+        #check turn amount
716
+        if carsetup.turnAmount[car] < turnAmount:
717
+            
718
+            #add to turn value
719
+            carsetup.turnAmount[car] += turnSpeed
720
+            
721
+            #apply steering
722
+            vehicleID.setSteeringValue(carsetup.turnAmount[car],0)
723
+            vehicleID.setSteeringValue(carsetup.turnAmount[car],1)
724
+    
725
+    #check if right is positive
726
+    #elif not left.positive and right.positive:
727
+    elif right == True:    
728
+        #check turn amount
729
+        if carsetup.turnAmount[car] > -turnAmount:
730
+            
731
+            #subtract from turn value
732
+            carsetup.turnAmount[car] -= turnSpeed
733
+            
734
+            #apply steering
735
+            vehicleID.setSteeringValue(carsetup.turnAmount[car],0)
736
+            vehicleID.setSteeringValue(carsetup.turnAmount[car],1)
737
+            
738
+    #check if none are positive
739
+    #elif not left.positive and not right.positive:
740
+    elif right == 0 and left == 0:
741
+        #print(round(carsetup.turnAmount[car],2))
742
+        #check if steering right
743
+        if carsetup.turnAmount[car] <= -turnSpeed2:
744
+            #print("less than, subtract")
745
+            #add to turn value
746
+            carsetup.turnAmount[car] += turnSpeed2
747
+        #check if steering left
748
+        elif carsetup.turnAmount[car] > turnSpeed2:
749
+            #print("greater than add")
750
+            #subtract from turn value
751
+            carsetup.turnAmount[car] -= turnSpeed2
752
+        else:
753
+            carsetup.turnAmount[car] = 0
754
+            
755
+        #apply steering
756
+        vehicleID.setSteeringValue(carsetup.turnAmount[car],0)
757
+        vehicleID.setSteeringValue(carsetup.turnAmount[car],1)
758
+
759
+def exit():
760
+    print('exit car')
761
+    scene = bge.logic.getCurrentScene()
762
+    dict = bge.logic.globalDict
763
+    cube = scene.objects['control_cube.002']
764
+    camera = scene.objects["Camera.003"]
765
+    own['driving'] = False
766
+    cube['driving'] = False
767
+    dict['driving_reset'] = True
768
+    cube.removeParent()
769
+    cube.applyMovement([0,-1,0], True)
770
+    cube.removeParent()
771
+    #cube.suspendDynamics(True)
772
+    cube.restoreDynamics()
773
+    #camobj = scene.objects['camobj']
774
+    #own.actuators['Camera'].object = camobj
775
+    scene.suspend()
776
+    
777
+    
778
+    
779
+def check_exit(yBut):
780
+    if yBut == True and dict['last_yBut'] == False:
781
+        exit()
782
+    else:
783
+        dict['last_driving'] = True    
784
+    
785
+def main(controller):
786
+
787
+    lLR = dict['lLR']
788
+    lUD = dict['lUD']
789
+    rLR = dict['rLR']
790
+    rUD = dict['rUD']
791
+    lTrig = dict['lTrig']
792
+    rTrig = dict['rTrig']
793
+    aBut = dict['aBut']
794
+    bBut = dict['bBut']
795
+    xBut = dict['xBut']
796
+    yBut = dict['yBut']
797
+    lBump = dict['lBump']
798
+    rBump = dict['rBump']
799
+    bkBut = dict['bkBut']
800
+    stBut = dict['stBut']
801
+    xbBut = dict['xbBut']
802
+    ltsBut = dict['ltsBut']
803
+    rtsBut = dict['rtsBut']
804
+    ldPad = dict['ldPad']
805
+    rdPad = dict['rdPad']
806
+    udPad = dict['udPad']
807
+    ddPad = dict['ddPad']
808
+
809
+    #no input
810
+    def cutOff():    
811
+     if (abs(lLR) < axisTh 
812
+         and abs(lUD) < axisTh 
813
+         and abs(rLR) < axisTh 
814
+         and abs(rUD) < axisTh
815
+         and aBut == False):        
816
+      return True
817
+
818
+    #print(rTrig)
819
+    own['ForwardSpeed'] = rTrig * 6500
820
+    #if own['ForwardSpeed'] < 500:
821
+        #own['ForwardSpeed'] = 500:
822
+    if rTrig > .01:
823
+        own['gas'] = 1
824
+    else:
825
+        own['gas'] = 0 
826
+    if lTrig > .01:
827
+        own['brake'] = 1
828
+    else:
829
+        own['brake'] = 0 
830
+    if lLR > .04:
831
+        own['right'] = 1
832
+    else:
833
+        own['right'] = 0
834
+    if lLR < -.04:
835
+        own['left'] = 1
836
+    else:
837
+        own['left'] = 0
838
+    if aBut == 1:
839
+        own['reverse'] = 1
840
+    else:
841
+        own['reverse'] = 0         
842
+                                   
843
+    
844
+    #get the car object
845
+    car = controller.owner
846
+    
847
+    #check if car was initialized
848
+    if not carsetup.carInitialized(car):
849
+        
850
+        #initialize the car
851
+        _initialize(controller)
852
+        
853
+        #exit
854
+        return
855
+    
856
+    #build the car constraint
857
+    vehicleID = _constraintID(car)
858
+    
859
+    #set tire grip
860
+    carsetup.tireGrip(car, vehicleID)
861
+    
862
+    #set suspension compression
863
+    carsetup.suspensionCompression(car, vehicleID)
864
+    
865
+    #set suspension damping
866
+    carsetup.suspensionDamping(car, vehicleID)
867
+    
868
+    #set suspension stiffness
869
+    carsetup.suspensionStiffness(car, vehicleID)
870
+    
871
+    #set suspension roll influence
872
+    carsetup.suspensionRollInfluence(car, vehicleID)
873
+    
874
+    #run powertrain
875
+    _powertrain(controller, car)
876
+    
877
+    #run powertrain
878
+    _steer(controller, car)
879
+    
880
+    check_exit(yBut)

+ 4851
- 0
scripts/co_ActionState.py
File diff suppressed because it is too large
View File


+ 170
- 0
scripts/colors.py View File

1
+import bge
2
+from bge import texture
3
+
4
+dict = bge.logic.globalDict 
5
+scene = bge.logic.getCurrentScene()
6
+shirt = scene.objects["Char4:Zshirtt1"]
7
+deck = scene.objects["deck"]
8
+throw_deck = scene.objectsInactive["throw_deck"]
9
+throw_deck_trucks = scene.objectsInactive["throw_deck_trucks"]
10
+focus_deckA = scene.objectsInactive["focus_deckA"]
11
+focus_deckB = scene.objectsInactive["focus_deckB"]
12
+focus_deckA_trucks = scene.objectsInactive["focus_deckA_trucks"]
13
+focus_deckB_trucks = scene.objectsInactive["focus_deckB_trucks"]
14
+shoeR = scene.objects['Char4:Shoes02.R']
15
+shoeL = scene.objects['Char4:Shoes02.L']
16
+trucks = scene.objects['trucks']
17
+wheel1 = scene.objects['rollen.000']
18
+wheel2 = scene.objects['rollen.001']
19
+wheel3 = scene.objects['rollen.002']
20
+wheel4 = scene.objects['rollen.003']
21
+throw_deck_wheel1 = scene.objectsInactive["throw_deck_trucks_wheels"]
22
+throw_deck_wheel2 = scene.objectsInactive["throw_deck_trucks_wheels.001"]
23
+throw_deck_wheel3 = scene.objectsInactive["throw_deck_trucks_wheels.002"]
24
+throw_deck_wheel4 = scene.objectsInactive["throw_deck_trucks_wheels.003"]
25
+focus_deckA_wheel1 = scene.objectsInactive['focus_deckA_wheel1']
26
+focus_deckA_wheel2 = scene.objectsInactive['focus_deckA_wheel2']
27
+focus_deckB_wheel1 = scene.objectsInactive['focus_deckB_wheel1']
28
+focus_deckB_wheel2 = scene.objectsInactive['focus_deckB_wheel2']
29
+
30
+
31
+##
32
+white = [ .9, .9, .9, 1.0]
33
+yellow = [ 0.6, 0.33, 0, 1.0]
34
+grey = [ .5, .5, .5, 1.0]
35
+red = [ .2, 0, 0, 1]
36
+orange = [.47, .1, 0, 1]
37
+deckbrown = [.2, .075, .001, 1]
38
+lightblue = [.375, .6, 1, 1]
39
+## set colors
40
+shirtC = white
41
+deckC = red
42
+shoesC = grey
43
+def main():
44
+
45
+    cont = bge.logic.getCurrentController()
46
+    own = cont.owner
47
+
48
+    #shirt.color = shirtC
49
+    #print(dict['shirt_color'])
50
+    scol = [dict['shirt_color_r'], dict['shirt_color_g'], dict['shirt_color_b'], 1]
51
+    deckC = [dict['deck_color_r'], dict['deck_color_g'], dict['deck_color_b'], 1]
52
+    print(scol)
53
+    shirt.color = scol
54
+    deck.color = deckC
55
+    throw_deck.color = deckC
56
+    focus_deckA.color = deckC
57
+    focus_deckB.color = deckC
58
+    shoesC = [dict['shoe_color_r'], dict['shoe_color_g'], dict['shoe_color_b'], 1]
59
+    shoeR.color = shoesC
60
+    shoeL.color = shoesC
61
+    
62
+    trucks.color = [dict['trucks_r'], dict['trucks_g'], dict['trucks_b'], 1]
63
+    throw_deck_trucks.color = [dict['trucks_r'], dict['trucks_g'], dict['trucks_b'], 1]
64
+    focus_deckA_trucks.color = [dict['trucks_r'], dict['trucks_g'], dict['trucks_b'], 1]
65
+    focus_deckB_trucks.color = [dict['trucks_r'], dict['trucks_g'], dict['trucks_b'], 1]
66
+    wheel1.color = [dict['wheel1_r'], dict['wheel1_g'], dict['wheel1_b'], 1]
67
+    wheel2.color = [dict['wheel2_r'], dict['wheel2_g'], dict['wheel2_b'], 1]
68
+    wheel3.color = [dict['wheel3_r'], dict['wheel3_g'], dict['wheel3_b'], 1]
69
+    wheel4.color = [dict['wheel4_r'], dict['wheel4_g'], dict['wheel4_b'], 1]
70
+    throw_deck_wheel1.color = [dict['wheel1_r'], dict['wheel1_g'], dict['wheel1_b'], 1]
71
+    throw_deck_wheel2.color = [dict['wheel2_r'], dict['wheel2_g'], dict['wheel2_b'], 1]
72
+    throw_deck_wheel3.color = [dict['wheel3_r'], dict['wheel3_g'], dict['wheel3_b'], 1]
73
+    throw_deck_wheel4.color = [dict['wheel4_r'], dict['wheel4_g'], dict['wheel4_b'], 1]
74
+    focus_deckA_wheel1.color = [dict['wheel1_r'], dict['wheel1_g'], dict['wheel1_b'], 1]
75
+    focus_deckA_wheel2.color = [dict['wheel2_r'], dict['wheel2_g'], dict['wheel2_b'], 1]
76
+    focus_deckB_wheel1.color = [dict['wheel3_r'], dict['wheel3_g'], dict['wheel3_b'], 1]
77
+    focus_deckB_wheel2.color = [dict['wheel4_r'], dict['wheel4_g'], dict['wheel4_b'], 1]    
78
+    
79
+    #print("set color", deck.color)
80
+
81
+
82
+    logo = dict['shirt_logo']
83
+    logo1 = shirt.meshes[0].materials[0].textures[6]
84
+    logo2 = shirt.meshes[0].materials[0].textures[7] 
85
+    logo3 = shirt.meshes[0].materials[0].textures[5]   
86
+    try:
87
+        if logo == 1:
88
+            logo1.diffuseIntensity = 1
89
+            logo2.diffuseIntensity = 0
90
+            logo1.diffuseFactor = 1
91
+            logo2.diffuseFactor = 0
92
+            logo3.diffuseIntensity = 0
93
+            logo3.diffuseFactor = 0
94
+        if logo == 2:
95
+            logo1.diffuseIntensity = 0
96
+            logo1.diffuseFactor = 0
97
+            logo2.diffuseIntensity = 1 
98
+            logo2.diffuseFactor = 1   
99
+            logo3.diffuseIntensity = 0
100
+            logo3.diffuseFactor = 0        
101
+        if logo == 3:
102
+            logo1.diffuseIntensity = 0
103
+            logo1.diffuseFactor = 0
104
+            logo2.diffuseIntensity = 0 
105
+            logo2.diffuseFactor = 0                   
106
+            logo3.diffuseIntensity = 1
107
+            logo3.diffuseFactor = 1        
108
+        if logo == 0:
109
+            logo1.diffuseIntensity = 0
110
+            logo2.diffuseIntensity = 0            
111
+            logo1.diffuseFactor = 0
112
+            logo2.diffuseFactor = 0
113
+            logo3.diffuseIntensity = 0
114
+            logo3.diffuseFactor = 0        
115
+    except:
116
+        pass    
117
+
118
+main()
119
+
120
+
121
+def update_truck_tex():
122
+    #deck graphic testing
123
+    #pass
124
+    import glob
125
+    scene = bge.logic.getCurrentScene()
126
+    deck = scene.objects["deck"]
127
+    mainDir = bge.logic.expandPath("//")
128
+    fileName = mainDir + "textures\\decks\\*.png"    
129
+    deckList = glob.glob(fileName)
130
+    dict['deckList'] = deckList  
131
+    ID = texture.materialID(deck, 'MAdeck')
132
+    deck_texture = texture.Texture(deck, ID)
133
+    new_source = texture.ImageFFmpeg(deckList[dict["deck_index"]])
134
+    bge.logic.texture = deck_texture
135
+    bge.logic.texture.source = new_source
136
+    bge.logic.texture.refresh(False)
137
+    deck_name = deckList[dict['deck_index']]
138
+    deck_name = deck_name.replace(mainDir, '')
139
+    deck_name = deck_name.replace('textures\decks', '' )
140
+    deck_name = deck_name.replace('.png', '')   
141
+    deck_name = deck_name.replace("\\", "")  
142
+    print('deck texture updted to ', deck_name)
143
+    dict['deck_name'] = deck_name
144
+    
145
+def update_shirt_tex():
146
+    #pass
147
+    #deck graphic testing
148
+    import glob
149
+    scene = bge.logic.getCurrentScene()
150
+    #deck = scene.objects["deck"]
151
+    shirt = scene.objects["Char4:Zshirtt1"]
152
+    mainDir = bge.logic.expandPath("//")
153
+    fileName2 = mainDir + "textures\\shirt\\*.png"    
154
+    shirtList = glob.glob(fileName2)
155
+    dict['shirtList'] = shirtList  
156
+    ID = texture.materialID(shirt, 'MAshirt')
157
+    shirt_texture = texture.Texture(shirt, ID)
158
+    new_source2 = texture.ImageFFmpeg(shirtList[dict["shirt_logo"]])
159
+    bge.logic.texture2 = shirt_texture
160
+    bge.logic.texture2.source = new_source2
161
+    bge.logic.texture2.refresh(False)
162
+    shirt_name = shirtList[dict['shirt_logo']]
163
+    shirt_name = shirt_name.replace(mainDir, '')
164
+    shirt_name = shirt_name.replace('textures\shirt', '' )
165
+    shirt_name = shirt_name.replace('.png', '')   
166
+    shirt_name = shirt_name.replace("\\", "")  
167
+    print('shirt texture updted to ', shirt_name)
168
+    dict['shirt_name'] = shirt_name    
169
+
170
+

+ 143
- 0
scripts/config_sample.ini View File

1
+#shuvit settings configuration file
2
+
3
+#debug
4
+######
5
+
6
+#show framerate
7
+framerate = 0
8
+#show profile
9
+profile = 0
10
+#----------
11
+
12
+#resolution
13
+###########
14
+
15
+resx = 1920
16
+resy = 1080
17
+fullscreen_on = 1
18
+music_player = 0
19
+#----------
20
+
21
+#level
22
+######
23
+level = warehouse
24
+#------------
25
+
26
+#replay recorder
27
+###############
28
+
29
+recorder_on = 1
30
+#--------------
31
+
32
+#camera 
33
+#######
34
+cam_height = -0.4
35
+focal_length = 10
36
+cam_min = 1.4
37
+cam_max = 2.0
38
+cch_targetHeight = 0.5
39
+
40
+
41
+#character settings
42
+###################
43
+
44
+character = becky
45
+
46
+shirt_logo = 1
47
+
48
+shirt_color_r = 0.35
49
+shirt_color_g = 0
50
+shirt_color_b = 0
51
+
52
+shoe_color_r = 0.23
53
+shoe_color_g = 0
54
+shoe_color_b = 0
55
+#-----------------
56
+
57
+#deck settings
58
+##############
59
+deck_index = 2
60
+deck_color_r = 1
61
+deck_color_g = 1.0
62
+deck_color_b = 1
63
+trucks_r = 0
64
+trucks_g = 0.53
65
+trucks_b = 0
66
+
67
+wheel1_r = 0.08
68
+wheel1_g = 0.08
69
+wheel1_b = 0.08
70
+wheel2_r = 0.08
71
+wheel2_g = 0.08
72
+wheel2_b = 0.08
73
+wheel3_r = 0.08
74
+wheel3_g = 0.08
75
+wheel3_b = 0.08
76
+wheel4_r = 0.08
77
+wheel4_g = 0.08
78
+wheel4_b = 0.08
79
+#-------------------
80
+
81
+#2d filter settings
82
+###################
83
+
84
+#brightness / contrast
85
+bc = 1
86
+BC_BRIGHTNESS = 1.3
87
+BC_CONTRAST = 1.0
88
+
89
+#HDR
90
+hdr = 1
91
+avgL = 0.7
92
+HDRamount = 0.65
93
+
94
+#Ambient Occlusion
95
+ao = 1
96
+onlyAO = 0
97
+aowidth = 1.0
98
+aoradius = 16
99
+
100
+#Depth of Field
101
+dof_on = 1
102
+
103
+#Bloom
104
+bloom_on = 1
105
+
106
+#FXAA
107
+fxaa = 1
108
+FXAA_SPAN_MAX = 8.0
109
+#-------------------
110
+
111
+#sun settings
112
+#############
113
+sun_strength = 0.9
114
+ambient_strength = 0.2
115
+sun_rot_x = -0.05
116
+sun_rot_y = -0.05
117
+shadow_on = 0
118
+#------------
119
+
120
+#physics
121
+########
122
+JUMPHEIGHT = 800
123
+MAX_VEL = 6.7
124
+SPEEDUP = 0.055
125
+SPEEDPUMP = 0.14#.09
126
+SPEEDPUMPFAST = 0.16#.13
127
+PUMP_SPEED_SENS = 0.4
128
+PUMP_SENS = 0.98
129
+ACCEL = 10
130
+CRUISE = 9
131
+COUNTDOWN = 20#pump and speed stuff
132
+pump_downforce = -0.1
133
+
134
+man_sens_l = 0.03
135
+man_sens_r = 0.08
136
+man_sens_side = 0.035
137
+turn_rotation = 0.02
138
+turn_addx = 0.004
139
+turn_air_rotation = 0.07
140
+grass_mult = 0.98
141
+ylimit = 0.84
142
+antibounce = -10.0
143
+gravity = -11

+ 17
- 0
scripts/contributing.md View File

1
+We'd love for you to be able to contribute to this project; if you're interested, you'll need the following:
2
+
3
+Latest stable version of UPBGE.
4
+The lastest release of Shuvit (v0.1.2b)
5
+The latest .blend file (shuvit_v0.1.2b.blend as of time of writing this)
6
+
7
+Now that you've got those, follow these steps:
8
+
9
+1. Put the .blend fild in the folder with the Shuvit executable
10
+2. Open UPBGE
11
+3. In UPBGE go to File > User Preferences. Select the "File" tab. Make sure "Auto Run Python Scripts" is checked. Save preferences.
12
+4. Choose File -> open
13
+5. Navigate to the folder where you put the .blend file and select it
14
+6. Click "open blender file" in UPBGE
15
+7. Wait for it to import
16
+8. ????
17
+9. Profit

+ 4351
- 0
scripts/controller2.py
File diff suppressed because it is too large
View File


+ 19
- 0
scripts/curves.osl View File

1
+
2
+
3
+uniform sampler2D bgl_RenderedTexture;
4
+
5
+uniform float BC_BRIGHTNESS = 2;
6
+uniform float BC_CONTRAST = 1;
7
+
8
+//const float BC_CONTRAST = 1.3;    //1 is no contrast.
9
+//const float BC_BRIGHTNESS = 1.15;    //1 is no brightness 1.15 is good
10
+
11
+void main()
12
+{
13
+    vec4 color = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
14
+    
15
+    color = ((color-1)*max(BC_CONTRAST,0));
16
+    color = color+BC_BRIGHTNESS;
17
+     
18
+    gl_FragColor = color; 
19
+}

+ 721
- 0
scripts/grindV2.py View File

1
+import bge
2
+import math
3
+
4
+def main():
5
+    cont = bge.logic.getCurrentController()
6
+    own = cont.owner
7
+    player = cont.owner
8
+    scene = bge.logic.getCurrentScene()
9
+    #grindDar = cont.sensors['grindDar']
10
+    grindEmpty = scene.objects['grindEmpty']
11
+    grindDar = grindEmpty.sensors['grindDar2']    
12
+    rGround = cont.sensors['r_Ground']
13
+    control_bottom = scene.objects['control_bottom']
14
+    #grindCol_bottom 
15
+    grindTouch = control_bottom.sensors['grindCol_bottom']
16
+    #grindTouch = cont.sensors['grindCol']
17
+    invertCol = cont.sensors['invertCol']
18
+    invertObjs = invertCol.hitObjectList
19
+    invert_on = own['invert_on']
20
+    detectedObjects = grindDar.hitObjectList
21
+    lastObject = own['grindTrackObj']
22
+    nearestObject = None
23
+    minDist = None
24
+    #act = cont.actuators["Target"]
25
+    test = own["test"]
26
+    grindold = own["grindOld"]
27
+    lgobj = own["lGobj"]
28
+    countdown = own['grindCountdown'] 
29
+    #print(lgobj)
30
+    ray = cont.sensors["GuardDuty"] # get the ray sensor attached to the controller named GuardDuty
31
+    gt_cd = own["gt_cd"]
32
+    pos = ray.hitPosition # get position where the game object hit by ray
33
+    linVelocity = own.getLinearVelocity(False)
34
+    linVelocity2 = own.getLinearVelocity(True)
35
+    pos[2] = pos[2] + 1 
36
+    norm = ray.hitNormal
37
+    STANCE = own["stance"]
38
+    orientation = own.worldOrientation
39
+    test = ray.hitObject
40
+    xyz = own.worldOrientation.to_euler()
41
+    rotz = math.degrees(xyz[2])
42
+    roty = math.degrees(xyz[1]) 
43
+    #print(roty)
44
+    roty = abs(roty) 
45
+    sub = 0
46
+    align_strength = .1#.3
47
+    align_strength2 = .2
48
+    touched = grindTouch.triggered
49
+    lgf = own['last_grind_frame']
50
+    gsf = own['grind_start_frame']
51
+    framenum = own['framenum']
52
+    last_ground_frame = own['lF_ground_frame']
53
+    frames_since_ground = framenum - last_ground_frame
54
+    frames_since_grind = framenum - lgf
55
+    frames_grinding = framenum - gsf
56
+    #if framenum - lgf > 60:
57
+    minus = framenum - gsf
58
+    grindspeed_rail = .996 #multiplied by current speed
59
+    grindspeed_cement = .995 #multiplied by current speed
60
+    grindDar_timer = own["grindDar_timer"]
61
+    last_grindDar = 0
62
+    last_manual = own["manual"]
63
+    joinit = 0
64
+    rot = own.getAxisVect( [0.0, 0.0, 1.0])
65
+    dropin = own['dropinTimer']
66
+    nearestObject = None
67
+    last_hit = own['grindDar_hit']
68
+    jump_timer = own['jump_timer']
69
+    grind_jump = own['grind_jump']
70
+    lastGround = own['lF_ground2']
71
+    OG_PLAYER_POS = own.worldPosition
72
+    grindvect = None
73
+    grindyvect = None
74
+    skipcol = 0
75
+    skipconst = 0
76
+    try:
77
+        no_grind_pull = own['no_grind_pull']
78
+    except:    
79
+        own['no_grind_pull'] = 0
80
+        no_grind_pull = 0
81
+        
82
+    since_jumped = framenum - own['last_jump_frame']    
83
+    #no grind
84
+    no_grind = 1
85
+    if jump_timer > 50:
86
+        own['no_grind_timer'] = 0
87
+    if own['no_grind_timer'] > 0:
88
+        no_grind = 0
89
+        own['no_grind_timer'] -= 1
90
+        
91
+    if grindold == 1:
92
+        no_grind = 0    
93
+    #don't grind unless you were in the air recently or were on a ramp recently or were grinding.
94
+    
95
+    #if (own['onramp'] == 0 and frames_since_grind > 30):
96
+        #no_grind = 1
97
+        
98
+    #if frames_since_grind > 30:
99
+        #no_grind = 0
100
+        
101
+    if frames_since_ground > 30 or since_jumped < 120:
102
+        no_grind = 0         
103
+    if jump_timer > 50:
104
+        no_grind = 1
105
+        
106
+   
107
+    #print('no grind timer', no_grind, own['no_grind_timer'])
108
+    
109
+    
110
+    if (own['fak_nmanual'] == 1 or own['reg_nmanual'] == 1 or own['fak_manual'] == 1 or own['reg_manual'] == 1):
111
+        manual = 1    
112
+    else:
113
+        manual = 0
114
+    #manual = own['manual']
115
+    own["nogrindsound"] = 0
116
+    
117
+#---------###########___###########-----------    
118
+#start new                     #######     
119
+##----------##############----------############
120
+
121
+#grindvect func
122
+    grindvect = None
123
+    grindyvect = None
124
+    lastobj = own["grindTouchobj"]
125
+    grindpos = own["grindpos"]
126
+    player_e = own.worldOrientation.to_euler()
127
+    player_rotz = math.degrees(player_e[2]) 
128
+    velxb = linVelocity2.x
129
+    player_e = own.worldOrientation.to_euler()
130
+    
131
+    ogrot = own.orientation
132
+    ogrot = player_e
133
+    
134
+    if (framenum - gsf) > 15:
135
+        velx = linVelocity2.x
136
+        vely = linVelocity2.y
137
+        #print("limit speed")
138
+    else:    
139
+         velx = linVelocity2.x
140
+         vely = linVelocity2.y     
141
+    if abs(own['pregrind_vely']) > abs(vely) and own['LAST_GRIND'] == 0:
142
+        #convely = own['pregrind_vely']
143
+        #print('changing convely')
144
+        convely = vely
145
+    else:
146
+        convely = vely  
147
+    def grindvect(obj):
148
+        STANCE = own['stance']
149
+        if obj != None:
150
+            grinder_e = obj.worldOrientation.to_euler()
151
+            grinder_rotz = math.degrees(grinder_e[2])            
152
+            rot = player_rotz - grinder_rotz
153
+        if rot >= 0 and rot < 45: 
154
+            grindvect = "pos"
155
+        if rot >= 45 and rot < 90: 
156
+            grindvect = "pos" 
157
+            grindyvect = "pos"
158
+        if rot >= 90 and rot < 135: 
159
+            grindvect = "neg"
160
+            grindyvect = "neg"
161
+        if rot >= 135 and rot < 180: 
162
+            grindvect = "neg"
163
+        if rot >= 180 and rot < 225: 
164
+            grindvect = "neg"
165
+        if rot >= 225 and rot < 270: 
166
+            grindvect = "neg"
167
+            grindyvect = "pos"
168
+        if rot >= 270 and rot < 315: 
169
+            grindvect = "pos" 
170
+            grindyvect = "neg"
171
+        if rot >= 315: 
172
+            grindvect = "pos"
173
+        if rot < 0 and rot >= -45: 
174
+            grindvect = "pos"
175
+        if rot < -45 and rot >= -90: 
176
+            grindvect = "pos"
177
+            grindyvect = "neg"
178
+        if rot < -90 and rot >= -135: 
179
+            grindvect = "neg"
180
+            grindyvect = "pos"
181
+        if rot < -135 and rot >= -180: 
182
+            grindvect = "neg"  
183
+        if rot < -180 and rot >= -225: 
184
+            grindvect = "neg" 
185
+        if rot < -225 and rot >= -270: 
186
+            grindvect = "neg"
187
+            grindyvect = "neg"
188
+        if rot < -270 and rot >= -315: 
189
+            grindvect = "pos" 
190
+            grindyvect = "pos"
191
+        if rot < -315: 
192
+            grindvect = "pos"   
193
+
194
+        rot = round((rot * .01), 1)
195
+        rot *= 100
196
+
197
+        #print(own['inverting'])
198
+        if frames_grinding > 20 and own['inverting'] == False: 
199
+            #print("setting stance")       
200
+            if (rot == 90 or rot == -270) and STANCE == True:
201
+                #print("90 fak stance")
202
+                own['stance'] = 1
203
+                STANCE = 1
204
+            if (rot == 90 or rot == -270) and STANCE == False:
205
+                #print("90 fak stance")
206
+                own['stance'] = 1
207
+                STANCE = 1
208
+            if (rot == -90 or rot == 270) and STANCE == True:
209
+                #print("-90 reg stance")
210
+                own['stance'] = 0
211
+                STANCE = 0
212
+            if (rot == -90 or rot == 270) and STANCE == False:
213
+                #print("-90 reg stance")                        
214
+                own['stance'] = 0
215
+                STANCE = 0
216
+    def grindrotvel(obj):        
217
+        skipconst = 1              
218
+        joinit = 0
219
+        grinder_e = obj.worldOrientation.to_euler()
220
+        grinder_rotz = math.degrees(grinder_e[2]) 
221
+        grinder_vect = obj.getAxisVect( [1, 0, 0]) 
222
+        grinder_vectz = obj.getAxisVect( [0, 0, 1]) 
223
+        rot = player_rotz - grinder_rotz        
224
+        rayhit = ray.hitObject
225
+        own['grind_rot'] = rot
226
+        vect = obj.getAxisVect( [1.0, 0.0, 0.0])
227
+        xyzb = obj.worldOrientation.to_euler()
228
+        rotzb = math.degrees(xyzb[2])   
229
+        grindpos = "None"         
230
+        align = "None"
231
+        sub_converted = 0
232
+        rotz = math.degrees(xyz[2])
233
+        roty = math.degrees(xyz[1])
234
+        bsrot = [ 0.0, 0.0, 1.570796327]    
235
+        negbsrot = [ 0.0, 0.0, -1.570796327]
236
+        zvel = own.linearVelocity
237
+        zvel = zvel.z * .95
238
+        if grindold == 0:
239
+            if rotz < 0:
240
+                rotz = rotz + 360
241
+            if rotzb < 0:
242
+                rotzb = rotzb + 360    
243
+            if rotz > rotzb:
244
+                sub_converted = rotz - rotzb
245
+            if rotz < rotzb:
246
+                sub_converted = rotzb - rotz
247
+
248
+        #z align
249
+        #print("zalign") 
250
+        stre = .15#.075#.15
251
+        player.alignAxisToVect(grinder_vectz, 2, stre)                                                  
252
+        
253
+        if rot >= 0 and rot < 45:
254
+            player.alignAxisToVect(grinder_vect, 0, align_strength)
255
+            grindvect = "pos"
256
+            #player.applyForce([0, 0, 0], True)            
257
+            player.setLinearVelocity([velxb, 0.0, zvel], 1)  
258
+            grindpos = "reg_5050"
259
+            #print("50-1")
260
+
261
+
262
+        elif rot >= 45 and rot < 90:  
263
+            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, 0], 0, align_strength)
264
+            grindvect = "pos"
265
+            align = "pos"            
266
+            player.setLinearVelocity([0, convely, zvel], 1)   
267
+            grindpos = "reg_board"     
268
+            grindyvect = "pos"
269
+            #print("bs1, don't switch")       
270
+                           
271
+        elif rot >= 90 and rot < 135:  
272
+            grinder_vect = grinder_vect * -1                
273
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength) 
274
+            grindvect = "neg"
275
+            align = "neg"
276
+            grindyvect = "neg"
277
+            player.setLinearVelocity([0, convely, zvel], 1)
278
+            grindpos = "reg_board"  
279
+            #print("-bs2, don't switch?")          
280
+                     
281
+        elif rot >= 135 and rot < 180:
282
+            player.alignAxisToVect(-grinder_vect, 0, align_strength)
283
+            grindvect = "neg"
284
+            player.setLinearVelocity([velxb, 0.0, zvel], 1) 
285
+            grindpos = "reg_5050"
286
+            #print("50-2")
287
+           
288
+        elif rot >= 180 and rot < 225:
289
+            player.alignAxisToVect(-grinder_vect, 0, align_strength)
290
+            grindvect = "neg"
291
+            player.setLinearVelocity([velxb, 0.0, zvel], 1)
292
+            grindpos = "reg_5050" 
293
+            #print("50-3")
294
+            
295
+        elif rot >= 225 and rot < 270:
296
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength)
297
+            grindvect = "neg"
298
+            align = "pos"
299
+            player.setLinearVelocity([0, convely, zvel], 1)
300
+            grindpos = "reg_board"
301
+            grindyvect = "pos"
302
+            #print("bs3")             
303
+           
304
+        elif rot >= 270 and rot < 315:
305
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength) 
306
+            grindvect = "pos" 
307
+            align = "neg"
308
+            player.setLinearVelocity([0, convely, zvel], 1)
309
+            grindpos = "reg_board"   
310
+            grindyvect = "neg"
311
+            #print("-bs4")          
312
+            
313
+        elif rot >= 315:
314
+            player.alignAxisToVect(grinder_vect, 0, align_strength)
315
+            grindvect = "pos"
316
+            player.setLinearVelocity([velxb, 0.0, zvel], 1)
317
+            grindpos = "reg_5050"
318
+            #print("50-4")
319
+                         
320
+#-------------------------------------------------------------            
321
+        elif rot < 0 and rot >= -45:
322
+            player.alignAxisToVect(grinder_vect, 0, align_strength)
323
+            grindvect = "pos"
324
+            player.setLinearVelocity([velxb, 0.0, zvel], 1)  
325
+            grindpos = "reg_5050" 
326
+            #print("50-5")                    
327
+        elif rot < -45 and rot >= -90:
328
+            grinder_vect = grinder_vect * -1
329
+            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, 0], 0, align_strength)
330
+            grindvect = "pos"
331
+            align = "neg"
332
+            player.setLinearVelocity([0, convely, zvel], 1)
333
+            grindpos = "reg_board"   
334
+            #print("-bs5")           
335
+            grindyvect = "neg"
336
+        elif rot < -90 and rot >= -135:
337
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength)
338
+            grindvect = "neg"
339
+            align = "pos"
340
+            player.setLinearVelocity([0, convely, zvel], 1)
341
+            grindpos = "reg_board"  
342
+            grindyvect = "pos"
343
+            #print("bs6")                   
344
+        elif rot < -135 and rot >= -180:
345
+            player.alignAxisToVect(-grinder_vect, 0, align_strength)
346
+            grindvect = "neg"   
347
+            player.setLinearVelocity([velxb, 0.0, zvel], 1)  
348
+            grindpos = "reg_5050" 
349
+            #print("50-6")       
350
+        elif rot < -180 and rot >= -225:
351
+            player.alignAxisToVect(-grinder_vect, 0, align_strength) 
352
+            grindvect = "neg"           
353
+            player.setLinearVelocity([velxb, 0.0, zvel], 1)  
354
+            grindpos = "reg_5050" 
355
+            #print("50-7")
356
+        elif rot < -225 and rot >= -270:
357
+            grinder_vect = grinder_vect * -1
358
+            player.alignAxisToVect([grinder_vect.y, -grinder_vect.x, 0], 0, align_strength) 
359
+            grindvect = "neg"
360
+            align = "neg"
361
+            player.setLinearVelocity([0, convely, zvel], 1)
362
+            grindpos = "reg_board"   
363
+            grindyvect = "neg"
364
+            #print("-bs7")              
365
+        elif rot < -270 and rot >= -315:
366
+            player.alignAxisToVect([-grinder_vect.y, grinder_vect.x, 0], 0, align_strength) 
367
+            grindvect = "pos"
368
+            align = "pos"
369
+            player.setLinearVelocity([0, convely, zvel], 1)
370
+            grindpos = "reg_board"    
371
+            grindyvect = "pos"
372
+            #print("bs8")                                   
373
+        elif rot < -315:
374
+            player.alignAxisToVect(grinder_vect, 0, align_strength) 
375
+            grindvect = "pos"                     
376
+            player.setLinearVelocity([velxb, 0.0, zvel], 1)  
377
+            grindpos = "reg_5050"  
378
+            #print("50-8")
379
+
380
+        own['grindpos'] = grindpos
381
+        own['grindvect'] = grindvect
382
+        own['grindervect'] = grinder_vect
383
+        try:   
384
+            own['grindyvect'] = grindyvect
385
+            
386
+        except:
387
+            pass 
388
+                
389
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
390
+    def grind(obj):
391
+        try:
392
+            grindyvect = own['grindyvect']
393
+        except:
394
+            grindyvect = 0 
395
+        grindvect = own['grindvect'] 
396
+        
397
+        if 'rail' in obj:
398
+            own["grindSound"] = "rail" 
399
+        else:
400
+            own["grindSound"] = "concrete"
401
+        own['lGobj'] = obj         
402
+        
403
+        grinding = 1                
404
+        
405
+        framenum = own['framenum']
406
+        lastairframe = own['lF_air_frame']
407
+        jumpside = 0
408
+        if (framenum - lastairframe) < 10:
409
+            player_pos = own['jumpPos'] 
410
+            jumpside = 1   
411
+        else:    
412
+            player_pos = OG_PLAYER_POS
413
+        player_pos = own.worldPosition    
414
+        try:    
415
+            if 1 == 1:       
416
+                grinder_pos = obj.worldPosition 
417
+                worldVect = [1, 0, 0]
418
+                vect = obj.getAxisVect(worldVect)      
419
+                go = obj.worldOrientation
420
+                grinder_axis = [0,1,0]
421
+                try: 
422
+                    delta = player_pos - grinder_pos
423
+                except:
424
+                    #print("delta broke: ", player_pos, grinder_pos)
425
+                    pass 
426
+                delta = delta.cross(vect)
427
+                if delta[2] >= 0:
428
+                    grindside = "right"
429
+
430
+                else:
431
+                    grindside = "left"
432
+                edge = 0
433
+                if 'edge' in obj:
434
+                    edge = 1    
435
+                #print('grind on', grindside, edge)
436
+                if (delta[2] > .00001 or delta[2] < -.00001) and (delta[2] < .8 or delta[2] < -.8):
437
+                    rotation = own.worldOrientation[2] - obj.worldOrientation[2]
438
+                    player_e = own.worldOrientation.to_euler()
439
+                    player_rotz = math.degrees(player_e[2])
440
+                    grinder_e = obj.worldOrientation.to_euler()
441
+                    grinder_rotz = math.degrees(grinder_e[2])
442
+                    deltamove = delta[2] * .3
443
+                    #print(round(deltamove, 4), "deltamove")
444
+                    #5050
445
+                    if own["grindpos"] == "reg_5050":
446
+                        #print("missing delta")
447
+                        if (jumpside == 1 or jumpside == 0) and grindvect == "pos":
448
+                            move = [0, deltamove, 0]
449
+                            #print("1deltamove", deltamove)
450
+                            own.applyMovement(move, True)    
451
+                        if (jumpside == 1 or jumpside == 0) and grindvect == "neg":
452
+                            move = [0, -deltamove, 0]
453
+                            #print("2deltamove -", deltamove)
454
+                            own.applyMovement(move, True)  
455
+                    #board
456
+                    if own["grindpos"] == "reg_board":
457
+                        if grindvect == "neg":
458
+                            if (jumpside == 1 or jumpside == 0) and grindyvect == "pos":
459
+                                move = [-deltamove, 0, 0]
460
+                                #print("3deltamove", deltamove)
461
+                                own.applyMovement(move, True)        
462
+                            if (jumpside == 1 or jumpside == 0) and grindyvect == "neg":
463
+                                move = [deltamove, 0, 0]
464
+                                #print("4deltamove -", deltamove)
465
+                                own.applyMovement(move, True)            
466
+                        if grindvect == "pos":
467
+                            if (jumpside == 1 or jumpside == 0) and grindyvect == "pos":
468
+                                move = [deltamove, 0, 0]
469
+                                #print("5deltamove", deltamove)
470
+                                own.applyMovement(move, True)        
471
+                            if (jumpside == 1 or jumpside == 0) and grindyvect == "neg":
472
+                                move = [-deltamove, 0, 0]
473
+                                own.applyMovement(move, True)                    
474
+                own['grindside'] = grindside    
475
+        except:
476
+            pass
477
+        #speed limit    
478
+        velo = own.getLinearVelocity(True)
479
+        touchobj = obj
480
+        if touchobj != None and gt_cd == 0:       
481
+            if 'rail' in touchobj:
482
+                newvelx = velo.x * grindspeed_rail   
483
+                newvely = velo.y * grindspeed_rail
484
+            else:
485
+                newvelx = velo.x * grindspeed_cement  
486
+                newvely = velo.y * grindspeed_cement            
487
+            player.setLinearVelocity([newvelx, newvely, velo.z], 1)   
488
+            player_rot = own.worldOrientation[2]
489
+            grinder_rot = touchobj.worldOrientation[2]
490
+            player_rot = own.getAxisVect( [0.0, 0.0, 1.0])
491
+            xyz3 = own.worldOrientation.to_euler()
492
+            player_rot = math.degrees(xyz3[2])
493
+            xyz4 = touchobj.worldOrientation.to_euler()
494
+            grinder_rot = math.degrees(xyz4[2]) 
495
+            if player_rot < 0:
496
+                player_rot = abs(player_rot) + 180
497
+            if grinder_rot < 0:
498
+                grinder_rot = abs(grinder_rot) + 180                   
499
+            subtraction = player_rot - grinder_rot
500
+        
501
+    def invertpos(detectedObjects):
502
+        minDist = None
503
+        nearestObject = None
504
+        for obj in detectedObjects:
505
+            dist = own.getDistanceTo(obj)
506
+            if (minDist is None or dist < minDist):
507
+                nearestObject = obj
508
+                minDist = dist
509
+        if nearestObject != None:                            
510
+            own.linearVelocity.x = 0
511
+            own.linearVelocity.y = 0            
512
+    
513
+    if grindDar.positive == False and grindTouch.triggered and grindold == 0 and dropin == 0 and grind_jump == 0 and own["grindoutturn"] == 0 and gt_cd == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject and own['grindjumpturn'] == 0 and own['gt_cd2'] == 0 and own['air_mover'] == False:
514
+        #print("touching, no dar")
515
+        pass
516
+    #print(grindold, "grindold")        
517
+    if (grindDar.positive or grindTouch.positive) and no_grind == 0:        
518
+        if grindDar.positive:
519
+            detectedObjects = grindDar.hitObjectList
520
+            dist = 0
521
+            for obj in detectedObjects:
522
+                dist = own.getDistanceTo(obj)
523
+                if (minDist is None or dist < minDist):
524
+                    nearestObject = obj
525
+                    minDist = dist     
526
+        elif grindTouch.positive:
527
+            nearestObject = grindTouch.hitObject
528
+            dist = .7
529
+            #print('using touch object')                    
530
+        
531
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
532
+        #init grind
533
+        
534
+        if invert_on:
535
+            invertpos(detectedObjects)
536
+            own['inverting'] = True
537
+        else:
538
+            own['inverting'] = False
539
+        grind_dist = .8#.6
540
+        #print(lastobj.worldPosition)
541
+        if dist < grind_dist and dropin == 0 and manual == 0 and no_grind == 0 and own['grindoutturn'] == 0 and own['manual'] == 0 and own['gt_cd2'] < 40 and invert_on == False and own['air_mover'] == False and no_grind_pull == 0 and own['last_invert'] == False and own['grindjumpturn'] == 0 and grind_jump == 0 and own['airup'] == 0:
542
+            #print('grind')      
543
+            hitObject, hitPoint, hitNormal = own.rayCast(nearestObject.worldPosition, own.worldPosition, .0, 'grind')
544
+            if grindold == 0:     
545
+                if grindTouch.triggered:
546
+                    nearpos = nearestObject.worldPosition
547
+                    if hitNormal != None:
548
+                        stre = .45
549
+                        own.alignAxisToVect(hitNormal, 2, stre) 
550
+                        #print("align")                   
551
+                    own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
552
+                    #print('moving world')
553
+            #print("grinding")
554
+            grind_height_dif = (own.worldPosition[2] - nearestObject.worldPosition[2]) - .287
555
+            worldPos = own.worldPosition
556
+            if grind_height_dif > -.05:#02:
557
+                grindvect(nearestObject)          
558
+                grindrotvel(nearestObject)
559
+                grind(nearestObject)
560
+                grindold = True
561
+                own['grindold_timer'] = 0
562
+                own["grindHit"] = True
563
+                own['grindnew_timer'] += 1
564
+                
565
+                if own['grindnew_timer'] < 1:
566
+                    if grindTouch.triggered:
567
+                        nearpos = nearestObject.worldPosition
568
+                        if hitNormal != None:
569
+                            stre = .15
570
+                            own.alignAxisToVect(hitNormal, 2, stre) 
571
+                            #print("align")                   
572
+                        #own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
573
+                        #print('new moving world')                    
574
+
575
+    else:
576
+        #grindold = False 
577
+        own['grindold_timer'] += 1
578
+        own["grindHit"] = False
579
+        own['inverting'] = False   
580
+    
581
+    if own['grindold_timer'] > 5:
582
+        grindold = False
583
+        own['grind_start_frame'] = framenum
584
+        own["grindSound"] = None
585
+    
586
+    if own['grindHit'] == False:
587
+        own['grindnew_timer'] = 0  
588
+ 
589
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    
590
+       
591
+#if you are touching grinder and last_manual is off keep manual off
592
+    if (own['fak_nmanual'] == 1 or own['reg_nmanual'] == 1 or own['fak_manual'] == 1 or own['reg_manual'] == 1) and lastGround == True and grindold == False:
593
+        manual = 1
594
+        if last_manual == 0 and grindTouch.triggered == True:
595
+            manual = 0
596
+        own["nogrindsound"] = 1
597
+    grindhit = own["grindHit"]
598
+
599
+    if abs(own['pregrind_vely']) > abs(vely) and own['LAST_GRIND'] == 0:
600
+        convely = own['pregrind_vely']
601
+    else:
602
+        convely = vely    
603
+
604
+    off = 0
605
+
606
+    if touched == True:
607
+        own["grindTouchobj"] = grindTouch.hitObject
608
+    else:
609
+        own["grindTouchobj"] = None  
610
+ 
611
+    if ray.triggered and dropin == 0:
612
+        lgobj = ray.hitObject
613
+        own['lGobj'] = lgobj
614
+        obj = ray.hitObject
615
+        #prop = obj.get("property", None)
616
+        linVelocity3 = own.getLinearVelocity(True)
617
+        grindpos2 = own["grindpos"]
618
+        regboard = "reg_board"
619
+        fakboard = "fak_board"
620
+        if obj is not None:        
621
+            if 'rail' in ray.hitObject:
622
+                own["grindSound"] = "rail" 
623
+            else:
624
+                own["grindSound"] = "concrete"
625
+        own['lGobj'] = lgobj    
626
+    else:
627
+        lgobj = "empty"
628
+        own['lGobj'] = lgobj
629
+    def timer():
630
+        countdown = own["grindCountdown"]
631
+        if touched == 1:
632
+            countdown = 20
633
+        else:
634
+            countdown = countdown - 1
635
+        own['grindCountdown'] = countdown
636
+    def aligntimer():
637
+        if own['grindOld'] == 0 and ray.triggered == 1:
638
+            own['aligntimer'] = 20
639
+        if own['grindOld'] == 1 and ray.triggered == 1:
640
+            own['aligntimer'] = own['aligntimer'] - 1
641
+        if own['grindOld'] == 0 and ray.triggered == 0:
642
+            own['aligntimer'] = 0   
643
+
644
+    def invertpos():
645
+        minDist = None
646
+        nearestObject = None
647
+        for obj in invertObjs:
648
+            dist = own.getDistanceTo(obj)
649
+            if (minDist is None or dist < minDist):
650
+                nearestObject = obj
651
+                minDist = dist
652
+        vect = nearestObject.getAxisVect( [1.0, 0.0, 0.0])
653
+        #own.alignAxisToVect(vect, 0, 0)
654
+        own.worldPosition = [nearestObject.worldPosition.x, nearestObject.worldPosition.y, nearestObject.worldPosition.z +.1]
655
+       #own.setLinearVelocity([0, 0.0, 0], 1)                    
656
+            
657
+    def set_pregrind_vel():
658
+        if grindDar.triggered == False and ray.triggered == False:
659
+            own['pregrind_velx'] = linVelocity2.x
660
+            own['pregrind_vely'] = linVelocity2.y
661
+            own['pregrind_velz'] = linVelocity2.z
662
+            
663
+    def stop_bounce():
664
+        if grindTouch.triggered and no_grind == 0 and grind_jump == 0 and jump_timer < 30:
665
+            linVelocity4 = own.getLinearVelocity(True)
666
+            if linVelocity4.z > 0:
667
+                own.setLinearVelocity([linVelocity4.x, linVelocity4.y, 0], 1)
668
+                        
669
+    if jump_timer < 30 :
670
+        own['grind_jump'] = 0 
671
+    if grindold == False and ray.triggered:
672
+        own['grind_start_frame'] = own['framenum']  
673
+        
674
+    if grindDar_timer > 0:
675
+        grindDar_timer -= 1
676
+    if ray.triggered == False and touched == True  and own['footplant_on'] == False and manual == 0 and own['gt_cd2'] < 55 and own['grindoutturn'] == 0 and own['grindjumpturn'] == 0 :        
677
+        obj = grindTouch.hitObject 
678
+        try:
679
+            nearpos = obj.worldPosition
680
+        except:
681
+            pass    
682
+    if ray.triggered == False:
683
+        own["nogrindsound"] = 1 
684
+    def slow_roty():
685
+      #print(abs(roty - own['last_roty']))
686
+      #print(roty)                
687
+      
688
+      #if roted > 5:
689
+        #pass
690
+        #align slow  
691
+        constraint = cont.actuators['gConstraint']
692
+        if (own['framenum'] - own['grind_start_frame'] < 40) and touched == 1:
693
+          #print('limit rot')              
694
+          #constraint.damp = 80
695
+        #else:
696
+          #constraint.damp = 30
697
+        #constraint.rotDamp = 80
698
+            cont.activate(constraint) 
699
+        else:
700
+            cont.deactivate(constraint)      
701
+    timer()    
702
+    aligntimer()
703
+    stop_bounce() 
704
+    slow_roty()
705
+      
706
+                   
707
+    own['grindOld'] = grindold 
708
+    own['test'] = test
709
+    own['grindTrackObj'] = nearestObject
710
+    own['grindDar_hit'] = grindDar.positive
711
+    own['lastTouched'] = touched
712
+    own['grindTouch'] = grindTouch.triggered
713
+    own["grindDar_timer"] = grindDar_timer
714
+    own["last_grindDar"] = last_grindDar
715
+    own['last_roty'] = roty
716
+    linVelocity3 = own.getLinearVelocity(True)
717
+    set_pregrind_vel()
718
+    own['last_z'] = own.worldPosition.z
719
+    own["manual"] = manual
720
+
721
+main()

+ 258
- 0
scripts/inputs.py View File

1
+################################################
2
+#inputs.py                                     #
3
+#inputs to global dict                         #
4
+#shuvit.org                                    #
5
+################################################
6
+
7
+import bge
8
+from bge import events
9
+from bge import logic as G
10
+
11
+def main():
12
+#####
13
+    #init
14
+    cont = bge.logic.getCurrentController()
15
+    scene = bge.logic.getCurrentScene()
16
+    own = cont.owner
17
+    dict = bge.logic.globalDict #Get the global dictionary
18
+    aXis = cont.sensors['Joystick.001']
19
+    bUtt = cont.sensors['Joystick'] 
20
+    reduction = 400000
21
+    axisTh = 0.03  
22
+    
23
+    joy_con = dict['joy_con']  
24
+    scenes = bge.logic.getSceneList()
25
+        
26
+#hard controller mappings    
27
+    lar_lts = 0
28
+    uad_lts = 1
29
+    lar_rts = 2 
30
+    uad_rts = 3 
31
+    lt = 4 
32
+    rt = 5  
33
+    a_but = 0 
34
+    b_but = 1 
35
+    x_but = 2 
36
+    y_but = 3 
37
+    l_bump = 9 
38
+    r_bump = 10 
39
+    bk_but = 4 
40
+    st_but = 6 
41
+    xb_but = 5 
42
+    lts_pr = 7 
43
+    rts_pr = 8 
44
+    l_dp = 13 
45
+    r_dp = 14 
46
+    u_dp = 11 
47
+    d_dp = 12 
48
+
49
+    reduction = 400000
50
+    axisTh = 0.03   
51
+    
52
+    
53
+    keyboard = G.keyboard.events
54
+    # KEY BINDINGS
55
+    kb_a = events.AKEY 
56
+    kb_d = events.DKEY 
57
+    kb_w = events.WKEY
58
+    kb_s = events.SKEY
59
+    kb_q = events.QKEY
60
+    kb_e = events.EKEY
61
+    kb_z = events.ZKEY
62
+    kb_c = events.CKEY 
63
+    kb_q = events.QKEY      
64
+    kb_en = events.ENTERKEY   
65
+    kb_la = events.LEFTARROWKEY
66
+    kb_ra = events.RIGHTARROWKEY
67
+    kb_ua = events.UPARROWKEY
68
+    kb_da = events.DOWNARROWKEY
69
+    kb_lsh = events.LEFTSHIFTKEY
70
+    kb_space = events.SPACEKEY
71
+    #if keyboard[kb_a]:
72
+    #print(keyboard[kb_a])
73
+    
74
+    dict['last_kb_a'] = dict['kb_a']
75
+    dict['last_kb_d'] = dict['kb_d']
76
+    dict['last_kb_w'] = dict['kb_w']
77
+    dict['last_kb_s'] = dict['kb_s']
78
+    dict['last_kb_q'] = dict['kb_q']
79
+    dict['last_kb_e'] = dict['kb_e']
80
+    dict['last_kb_z'] = dict['kb_z']
81
+    dict['last_kb_c'] = dict['kb_c'] 
82
+    dict['last_kb_q'] = dict['kb_q']  
83
+    dict['last_kb_en'] = dict['kb_en']  
84
+    dict['last_kb_la'] = dict['kb_la']
85
+    dict['last_kb_ra'] = dict['kb_ra']
86
+    dict['last_kb_ua'] = dict['kb_ua']
87
+    dict['last_kb_da'] = dict['kb_da'] 
88
+    dict['last_kb_lsh'] = dict['kb_lsh'] 
89
+    dict['last_kb_space'] = dict['kb_space']    
90
+    
91
+    dict['kb_a'] = keyboard[kb_a]
92
+    dict['kb_d'] = keyboard[kb_d]
93
+    dict['kb_w'] = keyboard[kb_w]
94
+    dict['kb_s'] = keyboard[kb_s]
95
+    dict['kb_q'] = keyboard[kb_q]
96
+    dict['kb_e'] = keyboard[kb_e]
97
+    dict['kb_z'] = keyboard[kb_z]
98
+    dict['kb_c'] = keyboard[kb_c] 
99
+    dict['kb_q'] = keyboard[kb_q]    
100
+    dict['kb_en'] = keyboard[kb_en]
101
+    dict['kb_la'] = keyboard[kb_la]
102
+    dict['kb_ra'] = keyboard[kb_ra]
103
+    dict['kb_ua'] = keyboard[kb_ua]
104
+    dict['kb_da'] = keyboard[kb_da] 
105
+    dict['kb_lsh'] = keyboard[kb_lsh]
106
+    dict['kb_space'] = keyboard[kb_space]      
107
+    
108
+    
109
+    if not any(bge.logic.joysticks):
110
+        #print("joystick not connnected")
111
+        dict['joy_con'] = 0
112
+    else:    
113
+        dict['joy_con'] = 1 
114
+        
115
+    if dict['joy_con'] != dict['last_joy_con'] and own['counter'] > 500:
116
+        if dict['joy_con'] == 0 and dict['last_joy_con'] == 1:
117
+            if 'joy_warn' not in scenes:
118
+                #add scene
119
+                #print('print add joy overlay')
120
+                cont.activate(cont.actuators['add_controller'])
121
+        else:
122
+            if dict['joy_con'] == 1 and dict['last_joy_con'] == 0:
123
+                #remove scene            
124
+                #print('print remove joy overlay')            
125
+                cont.activate(cont.actuators['remove_controller'])
126
+#get controller axis value 0-100   
127
+    if dict['joy_con'] == 1: 
128
+        lLR = aXis.axisValues[lar_lts] / reduction 
129
+        lUD = aXis.axisValues[uad_lts] / reduction 
130
+        rLR = aXis.axisValues[lar_rts] / reduction 
131
+        rUD = aXis.axisValues[uad_rts] / reduction 
132
+        lTrig = aXis.axisValues[lt] / reduction 
133
+        rTrig = aXis.axisValues[rt] / reduction 
134
+
135
+        aBut = bUtt.getButtonStatus(a_but)
136
+        bBut = bUtt.getButtonStatus(b_but)
137
+        xBut = bUtt.getButtonStatus(x_but)
138
+        yBut = bUtt.getButtonStatus(y_but)
139
+        lBump = bUtt.getButtonStatus(l_bump)
140
+        rBump = bUtt.getButtonStatus(r_bump)
141
+        bkBut = bUtt.getButtonStatus(bk_but)
142
+        stBut = bUtt.getButtonStatus(st_but)
143
+        xbBut = bUtt.getButtonStatus(xb_but)
144
+        ltsBut = bUtt.getButtonStatus(lts_pr)
145
+        rtsBut = bUtt.getButtonStatus(rts_pr)
146
+        ldPad = bUtt.getButtonStatus(l_dp)
147
+        rdPad = bUtt.getButtonStatus(r_dp)
148
+        udPad = bUtt.getButtonStatus(u_dp)
149
+        ddPad = bUtt.getButtonStatus(d_dp)
150
+
151
+        
152
+        #create modified axis values
153
+        if lLR < -20:
154
+            lmLR = round((lLR + 20) / 80 * 100, 0) 
155
+        elif lLR > 20:
156
+            lmLR = round((lLR - 20) / 80 * 100, 0)
157
+        else: lmLR = 0  
158
+              
159
+        if lUD > 20:
160
+            lmUD = round((lUD - 20) / 80 * 100, 0)
161
+        elif lUD < -20:
162
+            lmUD = round((lUD + 20) / 80 * 100, 0)
163
+        else: lmUD = 0 
164
+
165
+        if rLR < -20:
166
+            rmLR = round((rLR + 20) / 80 * 100, 0)
167
+        elif rLR > 20:
168
+            rmLR = round((rLR - 20) / 80 * 100, 0)
169
+        else: rmLR = 0         
170
+        
171
+        if rUD > 20:
172
+            rmUD = round((rUD - 20) / 80 * 100, 0)
173
+        elif rUD < -20:
174
+            rmUD = round((rUD + 20) / 80 * 100, 0)
175
+        else: rmUD = 0 
176
+      
177
+        if lTrig > 3:
178
+            mTrig = lTrig * -1
179
+        elif rTrig > 3:
180
+            mTrig = rTrig    
181
+        else: mTrig = 0
182
+        #    
183
+
184
+      
185
+        
186
+        
187
+        dict['last_aBut'] = dict['aBut']
188
+        dict['last_bBut'] = dict['bBut']
189
+        dict['last_xBut'] = dict['xBut']
190
+        dict['last_yBut'] = dict['yBut']
191
+        dict['last_lBump'] = dict['lBump']
192
+        dict['last_rBump'] = dict['rBump']
193
+        dict['last_bkBut'] = dict['bkBut']
194
+        dict['last_stBut'] = dict['stBut']
195
+        dict['last_xbBut'] = dict['xbBut']
196
+        dict['last_ltsBut'] = dict['ltsBut']
197
+        dict['last_rtsBut'] = dict['rtsBut']
198
+        dict['last_ldPad'] = dict['ldPad']
199
+        dict['last_rdPad'] = dict['rdPad']
200
+        dict['last_udPad'] = dict['udPad']
201
+        dict['last_ddPad'] = dict['ddPad']
202
+        dict['last_rUD'] = dict['rUD']
203
+        dict['last_lUD'] = dict['lUD']
204
+        dict['last_rLR'] = dict['rLR']
205
+        dict['last_lLR'] = dict['lLR']
206
+        dict['last_rmUD'] = dict['rmUD']
207
+        dict['last_lmUD'] = dict['lmUD']
208
+        dict['last_rmLR'] = dict['rmLR']
209
+        dict['last_lmLR'] = dict['lmLR']
210
+        dict['last_mTrig'] = dict['mTrig'] 
211
+        dict['last_rTrig'] = dict['rTrig'] 
212
+        dict['last_lTrig'] = dict['lTrig']    
213
+
214
+        dict['aBut'] = aBut
215
+        dict['bBut'] = bBut
216
+        dict['xBut'] = xBut
217
+        dict['yBut'] = yBut
218
+        dict['lBump'] = lBump
219
+        dict['rBump'] = rBump
220
+        dict['bkBut'] = bkBut
221
+        dict['stBut'] = stBut
222
+        dict['xbBut'] = xbBut
223
+        dict['ltsBut'] = ltsBut
224
+        dict['rtsBut'] = rtsBut
225
+        dict['ldPad'] = ldPad
226
+        dict['rdPad'] = rdPad
227
+        dict['udPad'] = udPad
228
+        dict['ddPad'] = ddPad
229
+        dict['rUD'] = rUD
230
+        dict['lUD'] = lUD
231
+        dict['rLR'] = rLR
232
+        dict['lLR'] = lLR
233
+        dict['rmUD'] = rmUD
234
+        dict['lmUD'] = lmUD
235
+        dict['rmLR'] = rmLR
236
+        dict['lmLR'] = lmLR
237
+        dict['mTrig'] = mTrig
238
+        dict['rTrig'] = rTrig
239
+        dict['lTrig'] = lTrig
240
+        dict['last_joy_con'] = joy_con
241
+
242
+    if dict['driving_reset'] == True:
243
+        dict['driving_reset'] = False
244
+        level = dict['level']
245
+
246
+        scenelist = bge.logic.getSceneList()
247
+        if level in scenelist:
248
+            level = scenelist[level]
249
+            level.resume()
250
+            print('resuming', level)
251
+            cube = level.objects['control_cube.002']
252
+            #cube.suspendDynamics(False)
253
+            #print(scenelist)
254
+            cube.restoreDynamics()
255
+            print(cube.isSuspendDynamics)
256
+
257
+main()
258
+

+ 72
- 0
scripts/lensflare01.osl View File

1
+
2
+uniform sampler2D bgl_RenderedTexture;
3
+uniform float bgl_RenderedTextureWidth;
4
+uniform float bgl_RenderedTextureHeight;
5
+uniform float sunX;
6
+uniform float sunY;
7
+uniform float timer;
8
+uniform float sundirect;
9
+uniform float sunScale; 
10
+
11
+float noise( float n )
12
+{
13
+     return fract(sin(n+timer/2.0));
14
+}
15
+
16
+//float noise2(vec2 co){
17
+    //return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
18
+//}
19
+
20
+vec3 lensflare(vec2 uv,vec2 pos,float sunscale)
21
+{
22
+	vec2 main = uv-pos;
23
+	vec2 uvd = uv*(length(uv));
24
+	
25
+	float ang = atan(main.y, main.x);
26
+	float dist=length(main); dist = pow(dist,.1);
27
+	float n = noise1(vec2((ang-timer/9.0)*16.0,dist*32.0));
28
+	
29
+	float f0 = 1.0/(length(uv-pos)/sunscale+1.0);
30
+	
31
+	f0 = f0+f0*(sin((ang+timer/18.0 + noise1(abs(ang)+n/2.0)*2.0)*12.0)*.1+dist*.1+.8);
32
+
33
+	float f2 = max(1.0/(1.0+32.0*pow(length(uvd+0.8*pos),2.0)),.0)*00.25;
34
+	float f22 = max(1.0/(1.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*00.23;
35
+	float f23 = max(1.0/(1.0+32.0*pow(length(uvd+0.9*pos),2.0)),.0)*00.21;
36
+	
37
+	vec2 uvx = mix(uv,uvd,-0.5);
38
+	
39
+	float f4 = max(0.01-pow(length(uvx+0.4*pos),2.4),.0)*6.0;
40
+	float f42 = max(0.01-pow(length(uvx+0.45*pos),2.4),.0)*5.0;
41
+	float f43 = max(0.01-pow(length(uvx+0.5*pos),2.4),.0)*3.0;
42
+	
43
+	uvx = mix(uv,uvd,-.4);
44
+	
45
+	float f5 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0;
46
+	float f52 = max(0.01-pow(length(uvx+0.4*pos),5.5),.0)*2.0;
47
+	float f53 = max(0.01-pow(length(uvx+0.6*pos),5.5),.0)*2.0;
48
+	
49
+	uvx = mix(uv,uvd,-0.5);
50
+	
51
+	float f6 = max(0.01-pow(length(uvx-0.3*pos),1.6),.0)*6.0;
52
+	float f62 = max(0.01-pow(length(uvx-0.325*pos),1.6),.0)*3.0;
53
+	float f63 = max(0.01-pow(length(uvx-0.35*pos),1.6),.0)*5.0;
54
+	
55
+	vec3 c = vec3(.0);
56
+	
57
+	c.r+=f2+f4+f5+f6; c.g+=f22+f42+f52+f62; c.b+=f23+f43+f53+f63;
58
+	c+=vec3(f0);
59
+	
60
+	return c;
61
+}
62
+
63
+void main()
64
+{
65
+    vec4 renderedTex = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
66
+    float xconv = bgl_RenderedTextureWidth / bgl_RenderedTextureHeight;
67
+    vec2 sunPos = vec2((sunX - 0.5) * xconv, sunY - 0.5);
68
+    vec2 uv = vec2((gl_TexCoord[0].s - 0.5) * xconv, gl_TexCoord[0].t - 0.5);
69
+    vec3 lens = lensflare(uv, sunPos, sunScale);
70
+    renderedTex.rgb += lens * sundirect;
71
+    gl_FragColor = renderedTex;
72
+}

+ 65
- 0
scripts/load_char.py View File

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

+ 139
- 0
scripts/load_npc.py View File

1
+
2
+import bge
3
+from mathutils import Vector
4
+
5
+def rot_deck(cont):
6
+      
7
+    scene = bge.logic.getCurrentScene()
8
+    deck = scene.objects['npc_ed_deck']
9
+    #rot = [ 0.0, 0.0, -1.570796327]
10
+    print('rotating')
11
+    deck.alignAxisToVect(Vector([1,0,0]),2,.25) 
12
+    #rot = [ 0.0, 0.0, -0.10796327]
13
+    #deck.applyRotation(rot,True) 
14
+    #print('rotating')    
15
+    
16
+def collect_npc(cont):
17
+    #add ed
18
+    own = cont.owner
19
+    scene = bge.logic.getCurrentScene()
20
+    dict = bge.logic.globalDict
21
+    objList = scene.objects   
22
+    
23
+    try:
24
+        spawned_list = dict['spawned_npc_list']
25
+        to_spawn = dict['to_spawn']
26
+    except:
27
+        dict['spawned_npc_list'] = []  
28
+        dict['to_spawn'] = []  
29
+        to_spawn = [] 
30
+        own['npc_index'] = 0
31
+    
32
+    npc_index = 0
33
+    for x in objList:
34
+        
35
+        if 'npc_skater' in x:
36
+            
37
+            dict['to_spawn'].append(x)
38
+            print(x.name, 'added to list')
39
+            
40
+def spawn_npc(cont):
41
+    own = cont.owner
42
+    scene = bge.logic.getCurrentScene()
43
+    dict = bge.logic.globalDict
44
+    objList = scene.objects 
45
+    to_spawn = dict['to_spawn']
46
+    #print(to_spawn)
47
+    npc_index = own['npc_index']
48
+    
49
+    if to_spawn:
50
+        x = dict['to_spawn'][0]  
51
+        print(x) 
52
+        
53
+        x['rpStartLoc'] = [0.0,0.0,0.0] 
54
+        x['rpStartLoc_set'] = False
55
+        x['move'] = False  
56
+        x['npc_rotate'] = False 
57
+        x['rotate_in'] = False
58
+        x['move_to'] = False
59
+        x['rotate_out'] = False      
60
+
61
+        obj = scene.addObject('npc_ed_deck', own, 0)
62
+        obj.setParent(x, False, False)            
63
+        dict['spawned_npc_decks'].append(obj)
64
+        obj = scene.addObject('npc_ed_trucks', own, 0)
65
+        obj.setParent(x, False, False)            
66
+        dict['spawned_npc_trucks'].append(obj)
67
+        obj = scene.addObject('npc_ed_arm', own, 0)
68
+        obj.setParent(x, False, False)
69
+        dict['spawned_npcs'].append(obj)
70
+                
71
+        if npc_index == 0:        
72
+            shirt = obj.children["npc:Zshirtt1"]
73
+            shirt.color = [.9,.1,.1,1]
74
+        if npc_index == 1:        
75
+            shirt = obj.children["npc:Zshirtt1"]
76
+            shirt.color = [.1,.9,.1,1]
77
+        if npc_index == 2:        
78
+            shirt = obj.children["npc:Zshirtt1"]
79
+            shirt.color = [.1,.1,.9,1]                        
80
+        
81
+        
82
+        #rot = [ 0.0, 0.0, 1.570796327]
83
+        x['npc_index'] = npc_index
84
+        npc_index += 1
85
+        own['npc_index'] = npc_index
86
+        print('adding npc character: ', x.name, obj.name)
87
+        dict['to_spawn'].remove(x)
88
+        
89
+        shirt = scene.objects["npc:Zshirtt1"]
90
+        shirt.color = [255,0,0,1]
91
+    
92
+def main():  
93
+    cont = bge.logic.getCurrentController()
94
+    own = cont.owner
95
+    scene = bge.logic.getCurrentScene()
96
+    #actu = cont.actuators['start_level']
97
+    dict = bge.logic.globalDict
98
+    objList = scene.objects
99
+    mainDir = bge.logic.expandPath("//")
100
+    skater = 'ai_ed'
101
+    
102
+    fileName = mainDir + "npc_skaters/" + str(skater) + '.blend'    
103
+    
104
+    path = bge.logic.expandPath(fileName)
105
+    try:
106
+        bge.logic.LibLoad(path, 'Scene') 
107
+    except:
108
+        print('trying to load', fileName, 'twice')    
109
+    
110
+
111
+    # get object named MainCharacter
112
+    #armature = objList["npc_ed_arm"]
113
+    #deck = objList['npc_ed_deck']
114
+    #trucks = objList['npc_ed_trucks']
115
+
116
+    # combine child's shape with parent's
117
+    compound = False
118
+
119
+    # child is solid
120
+    ghost = False
121
+    
122
+    # rotate the game object 1.570796327 radians (90 degrees)
123
+    #rot = [ 0.0, 0.0, -1.570796327]
124
+    #deck.applyRotation(rot,False)     
125
+
126
+    # set parent
127
+    #for x in [armature, deck, trucks]:
128
+        #x.setParent( own, compound, ghost) 
129
+        #rot = [ 0.0, 0.0, -1.570796327]
130
+        #deck.applyRotation(rot,True)     
131
+            
132
+
133
+       
134
+    #rot = [ 0.0, 0.0, -1.570796327]
135
+    #deck.applyRotation(rot,True) 
136
+    print('loading ai') 
137
+
138
+main()
139
+        

+ 1509
- 0
scripts/menuV3.py
File diff suppressed because it is too large
View File


+ 166
- 0
scripts/music_player.py View File

1
+#shuvit.org
2
+#mp3 player
3
+
4
+import bge
5
+import os
6
+import aud
7
+import random
8
+import glob
9
+from tinytag import TinyTag
10
+
11
+# dict
12
+dict = bge.logic.globalDict
13
+dict['mu_current_song'] = ''
14
+dict['mu_stopped'] = 1
15
+dict['change_track'] = 0
16
+dict['mu_track_time'] = 0
17
+
18
+# create file path
19
+directory = bge.logic.expandPath("//")
20
+file_name = directory + "Music\\*.mp3" # Test directory "Test\\Music\\*.mp3"
21
+file_list = glob.glob(file_name)
22
+selected = random.choice(file_list)
23
+full_path = os.path.join(directory, selected)
24
+dict['mu_playlist'] = file_list
25
+dict['mu_lib'] = file_list
26
+
27
+# inputs
28
+keyboard = bge.logic.keyboard
29
+JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
30
+
31
+def initer(cont):
32
+    own = cont.owner
33
+    dict = bge.logic.globalDict
34
+    if 'mplayback' not in dict:
35
+        dict['mplayback'] = True
36
+    if 'mp_inited' not in own:
37
+        own['mp_inited'] = True
38
+        print('Initializing music player')
39
+        
40
+        dict['mu_lib'] = file_list
41
+        dict['mu_playlist'] = file_list
42
+        dict['change_track'] = 0
43
+        selected = random.choice(file_list)
44
+        dict['mu_current_song'] = selected
45
+        print('Current Track: ', dict['mu_current_song'])
46
+        full_path = os.path.join(directory, selected)
47
+
48
+        try:
49
+            tag = TinyTag.get(full_path)
50
+            print('Artist: %s' % tag.artist, 'Track: %s' % tag.title)
51
+            dict['mu_artist'] = tag.artist
52
+            dict['mu_title'] = tag.title            
53
+        except:
54
+            print("Track has no tag.")  
55
+            
56
+def stop_music(sound):
57
+
58
+    print("Stop music")    
59
+    sound.pauseSound()
60
+    dict['mu_stopped'] = 1
61
+    dict['music_player'] = 0
62
+    
63
+def play_music():
64
+
65
+    print("Play music") 
66
+    full_path = os.path.join(directory, dict['mu_current_song'])
67
+    sound = bge.logic.getCurrentController().actuators['music_player']
68
+    sound.sound = aud.Factory(full_path)
69
+    sound.stopSound()
70
+    sound.startSound()
71
+    dict['mu_stopped'] = 0
72
+    dict['change_track'] = 0
73
+    dict['mu_track_time'] = 0 
74
+    dict['music_player'] = 1  
75
+    try:
76
+        tag = TinyTag.get(full_path)
77
+        print('Playing: ', 'Artist: %s' % tag.artist, 'Track: %s' % tag.title)
78
+        dict['mu_artist'] = tag.artist
79
+        dict['mu_title'] = tag.title
80
+        info = ('Music > ', 'Artist: %s' % tag.artist, 'Track: %s' % tag.title)
81
+        dict['music_info'] = info
82
+    except:
83
+        print("Track has no tag.") 
84
+    print(dict['mu_title'], 'mu_title')
85
+    
86
+def next_track():
87
+
88
+    print("next track")
89
+    dict = bge.logic.globalDict
90
+    plist = dict['mu_playlist']
91
+    cur_song = dict['mu_current_song']
92
+    pl_length = len(dict['mu_playlist'])    
93
+
94
+    if pl_length > 1:
95
+        try:
96
+            plist.remove(cur_song)
97
+        except:
98
+            pass    
99
+
100
+    if pl_length == 1:    
101
+        print('rebuilding playlist')
102
+        file_list = glob.glob(file_name)
103
+        plist = file_list
104
+
105
+    selected = random.choice(plist)
106
+    dict['mu_last_track'] = dict['mu_current_song']
107
+    dict['mu_current_song'] = selected
108
+    dict['mu_playlist'] = plist
109
+    dict['change_track'] = 0
110
+    dict['mu_track_time'] = 0
111
+    play_music()
112
+
113
+def previous_track():
114
+
115
+    print("previous track") 
116
+    dict['mu_current_song'] = dict['mu_last_track']
117
+    play_music()   
118
+
119
+def check_status():
120
+
121
+    sound = bge.logic.getCurrentController().actuators['music_player']
122
+    cur_song = dict['mu_current_song']
123
+    full_path = os.path.join(directory, dict['mu_current_song'])
124
+    sound = bge.logic.getCurrentController().actuators['music_player']
125
+    sound.sound = aud.Factory(full_path)  
126
+
127
+    if sound.time < dict['mu_track_time'] and dict['mu_stopped'] == 0 and dict['change_track'] == 0:
128
+        print('song over, getting new one')
129
+        dict['change_track'] = 1
130
+        dict['mu_track_time'] = 0
131
+    else:
132
+        dict['change_track'] = 0
133
+    dict['mu_track_time'] = sound.time    
134
+
135
+def main(cont):
136
+
137
+    dict = bge.logic.globalDict        
138
+    cur_song = dict['mu_current_song']    
139
+    full_path = os.path.join(directory, dict['mu_current_song'])
140
+    sound = bge.logic.getCurrentController().actuators['music_player']
141
+    sound.sound = aud.Factory(full_path)
142
+    sound.mode = 1
143
+    initer(cont)
144
+    if dict['music_player'] != 0:
145
+        if dict['mu_stopped'] == 1:        
146
+            play_music()
147
+        if dict['change_track'] == 1:
148
+            dict['change_track'] = 0
149
+            next_track() 
150
+
151
+    plist = dict['mu_playlist']  
152
+    pl_length = len(dict['mu_playlist'])    
153
+    if pl_length == 0:
154
+        dict['mu_playlist'] = dict['mu_lib']       
155
+         
156
+    #allow controlls while paused or in replay    
157
+    if dict['npause']  == 1 or dict['playback'] == True:
158
+        if dict['yBut'] == False and dict['last_yBut'] == True:
159
+            if dict['mu_stopped'] == 1:
160
+                play_music() 
161
+            else:
162
+                stop_music(sound)  
163
+        if dict['lBump'] == False and dict['last_lBump'] == True:
164
+            previous_track()
165
+        if dict['rBump'] == False and dict['last_rBump'] == True:
166
+            next_track() 

+ 134
- 0
scripts/npause.py View File

1
+import bge
2
+import menuV3
3
+import Settings
4
+
5
+
6
+#replay huds:
7
+#add_hud
8
+#remove_hud (on control_cube)
9
+
10
+def main():
11
+
12
+    cont = bge.logic.getCurrentController()
13
+    scene = bge.logic.getCurrentScene()
14
+    dict = bge.logic.globalDict 
15
+    
16
+    skater = scene.objects["Char4"]
17
+    deck = scene.objects["deck"]
18
+    trucks = scene.objects["trucks"]
19
+    own = scene.objects["control_cube.002"]
20
+    
21
+    camList = scene.cameras
22
+    freecam = camList["freecam"] 
23
+    mcam = camList['Camera.003']   
24
+    
25
+    cube = scene.objects['control_cube.002']
26
+    
27
+    try:
28
+        pause_state = dict['npause']
29
+        last_pause = dict['last_npause']
30
+    except:
31
+        dict['npause'] = 0
32
+        dict['last_npause'] = 0
33
+        pause_state = 0
34
+        last_pause = 0
35
+
36
+
37
+    def printplaying():
38
+        splaying_layers = "S: "
39
+        playing_layers = "D: "
40
+        tplaying_layers = "T: "
41
+        for x in range(1000):
42
+            if skater.isPlayingAction(x):
43
+            #if trucks.isPlayingAction(x):
44
+            #if skater.isPlayingAction(x):                        
45
+                splaying_layers += str(x)
46
+                splaying_layers += " "        
47
+            if deck.isPlayingAction(x):
48
+            #if trucks.isPlayingAction(x):
49
+            #if skater.isPlayingAction(x):                        
50
+                playing_layers += str(x)
51
+                playing_layers += " "
52
+            if trucks.isPlayingAction(x):
53
+            #if trucks.isPlayingAction(x):
54
+            #if skater.isPlayingAction(x):                        
55
+                tplaying_layers += str(x)
56
+                tplaying_layers += " "            
57
+        print(splaying_layers, playing_layers, tplaying_layers)
58
+
59
+    
60
+    #switch pause state
61
+    if dict['stBut'] == True and dict['last_stBut'] == False:
62
+        if pause_state == 0:
63
+            pause_state = 1
64
+        else:
65
+            pause_state = 0    
66
+        dict['npause'] = pause_state
67
+    
68
+    #enter pause    
69
+    if pause_state == 1 and last_pause == 0:
70
+        own.suspendDynamics()
71
+        own['pre_pause_linvel'] = [own['linvelx'], own['linVely'], 0]
72
+        own.setLinearVelocity([0,0,0],1)  
73
+        cont.activate(cont.actuators['empty'])
74
+        if mcam['playback'] == False:
75
+            cont.activate(cont.actuators['add_overlay']) 
76
+        cont.activate(cont.actuators['remove_stance'])  
77
+        cube['camera'] = 2
78
+        cube['camnum'] = 2 
79
+        scene.active_camera = freecam 
80
+        freecam.lens = mcam['focal_length'] 
81
+        freecam.worldPosition = mcam.worldPosition
82
+        freecam.worldOrientation = mcam.worldOrientation                      
83
+
84
+    if pause_state == 1: 
85
+        if mcam['playback'] == False:       
86
+            layer = 2
87
+            if skater.isPlayingAction(layer):
88
+                skater.stopAction(layer)
89
+            if deck.isPlayingAction(layer):    
90
+                deck.stopAction(layer)
91
+            if trucks.isPlayingAction(layer):    
92
+                trucks.stopAction(layer)
93
+            layer = 3
94
+            if skater.isPlayingAction(layer):
95
+                skater.stopAction(layer)
96
+            if deck.isPlayingAction(layer):    
97
+                deck.stopAction(layer)
98
+            if trucks.isPlayingAction(layer):    
99
+                trucks.stopAction(layer)
100
+            layer = 4
101
+            if skater.isPlayingAction(layer):
102
+                skater.stopAction(layer)
103
+            if deck.isPlayingAction(layer):    
104
+                deck.stopAction(layer)
105
+            if trucks.isPlayingAction(layer):    
106
+                trucks.stopAction(layer)
107
+        menuV3.main(cont)                                                    
108
+                
109
+    #exit pause     
110
+    if pause_state == 0 and last_pause == 1:
111
+        Settings.writeSettings()
112
+        Settings.writeChar()
113
+        own.restoreDynamics()
114
+
115
+        if own['walk'] == False:
116
+            cont.activate(cont.actuators['roll'])
117
+        else:
118
+            cont.activate(cont.actuators['walk'])    
119
+        try:
120
+            own.setLinearVelocity(own['pre_pause_linvel'], 1) 
121
+        except:
122
+            pass    
123
+        cont.activate(cont.actuators['remove_overlay'])  
124
+        cont.activate(cont.actuators['add_stance']) 
125
+        
126
+    if pause_state == 1 and dict['rtsBut'] == False and dict['last_rtsBut'] == True:
127
+        scenes = bge.logic.getSceneList()
128
+        if 'pause' in scenes:    
129
+            cont.activate(cont.actuators['remove_overlay']) 
130
+        else:
131
+            cont.activate(cont.actuators['add_overlay'])                                   
132
+    dict['last_npause'] = pause_state
133
+    
134
+main()

+ 48
- 0
scripts/npcChangeAnim.py View File

1
+#npcChangeAnim
2
+
3
+import bge
4
+import random
5
+
6
+a_starts = ['20secA.dat', '20secE.dat', 'shopSaEa40a.dat', 'shopSaEb40a.dat', 'shopSaEb20a.dat', 'shopSaEa30a.dat']
7
+a_ends = ['20secA.dat', '20secE.dat', 'shopSaEa40a.dat', 'shopSbEa50a.dat', 'shopSbEa60a.dat', 'shopSaEa30a.dat']
8
+b_starts = ['shopSbEb40sec.dat', 'shopSbEa50a.dat', 'shopSbEa60a.dat', 'shopSbEb50a.dat']
9
+b_ends = ['shopSbEb40sec.dat', 'shopSaEb40a.dat', 'shopSaEb20a.dat', 'shopSbEb50a.dat']
10
+
11
+def main(cont):
12
+    own = cont.owner
13
+    own['npc_playback'] = False
14
+    
15
+    if own['npc_replay_name'] in a_ends:
16
+        num = len(a_starts) - 1
17
+        ran = random.randint(0,num)
18
+        own['npc_replay_name'] = a_starts[ran]
19
+    elif own['npc_replay_name'] in b_ends:
20
+        num = len(b_starts) - 1
21
+        ran = random.randint(0,num)
22
+        own['npc_replay_name'] = b_starts[ran]        
23
+    
24
+    if own['npc_replay_name'] == '20secA.dat':
25
+        own['replay_length'] = 2400
26
+    if own['npc_replay_name'] == '20secE.dat':
27
+        own['replay_length'] = 2400    
28
+    if own['npc_replay_name'] == 'shopSaEa40a.dat':
29
+        own['replay_length'] = 6500 
30
+    if own['npc_replay_name'] == 'shopSaEb40a.dat':
31
+        own['replay_length'] = 5500  
32
+    if own['npc_replay_name'] == 'shopSbEa50a.dat':
33
+        own['replay_length'] = 6500  
34
+    if own['npc_replay_name'] == 'shopSbEb40sec.dat':
35
+        own['replay_length'] = 6500 
36
+    if own['npc_replay_name'] == 'shopSaEb20a.dat':
37
+        own['replay_length'] = 2300     
38
+    if own['npc_replay_name'] == 'shopSbEa60a.dat':
39
+        own['replay_length'] = 7100 
40
+    if own['npc_replay_name'] == 'shopSaEa30a.dat':
41
+        own['replay_length'] = 3200 
42
+    if own['npc_replay_name'] == 'shopSbEb50a.dat':
43
+        own['replay_length'] = 6000                                             
44
+
45
+    print('Playing NPC-Replay:', own['npc_replay_name'])
46
+
47
+    
48
+    own['rpStartLoc_set'] = False  

+ 350
- 0
scripts/pause.py View File

1
+import bge
2
+cont = bge.logic.getCurrentController()
3
+own = cont.owner
4
+dict = bge.logic.globalDict
5
+
6
+lLR = dict['lLR']
7
+lUD = dict['lUD']
8
+rLR = dict['rLR']
9
+rUD = dict['rUD']
10
+lTrig = dict['lTrig']
11
+rTrig = dict['rTrig']
12
+aBut = dict['aBut']
13
+bBut = dict['bBut']
14
+xBut = dict['xBut']
15
+yBut = dict['yBut']
16
+lBump = dict['lBump']
17
+rBump = dict['rBump']
18
+bkBut = dict['bkBut']
19
+stBut = dict['stBut']
20
+xbBut = dict['xbBut']
21
+ltsBut = dict['ltsBut']
22
+rtsBut = dict['rtsBut']
23
+ldPad = dict['ldPad']
24
+rdPad = dict['rdPad']
25
+udPad = dict['udPad']
26
+ddPad = dict['ddPad']
27
+
28
+#print(lUD)
29
+axis_sens = .06
30
+#print(aBut)
31
+lasta = own["lasta"]
32
+
33
+if lUD > axis_sens: down = 1
34
+else: down = 0    
35
+if lUD < -axis_sens: 
36
+    up = 1 
37
+    #print("up")
38
+else: up = 0    
39
+#print(down, up)
40
+if lLR > axis_sens: right = 1
41
+else: right = 0 
42
+if lLR < -axis_sens: left = 1
43
+else: left = 0 
44
+
45
+fileName = "Settings.dat"
46
+scenes = bge.logic.getSceneList()
47
+#print(scenes)
48
+main_scene = [scene for scene in scenes if scene.name=="main"][0]
49
+main_empty = main_scene.objects['Empty']
50
+
51
+def main():
52
+
53
+    cont = bge.logic.getCurrentController()
54
+    own = cont.owner
55
+    #down = cont.sensors["down"]
56
+    #up = cont.sensors["up"]
57
+    #bBut = cont.sensors["bBut"]
58
+    #aBut = cont.sensors["aBut"]
59
+    pstate = own["pstate"]
60
+    scene = bge.logic.getCurrentScene()
61
+    dict = bge.logic.globalDict
62
+#    resume = scene.objects["resume"]
63
+#    settings = scene.objects["settings"]
64
+    #level = scene.objects["level"]
65
+#    dict['level'] = level
66
+#    levelselect = scene.objects["levelselect"]
67
+#    restart = scene.objects["restart"]
68
+#    exit = scene.objects["exit"]
69
+#    submenu_on = own["submenu_on"]
70
+#    level_text = scene.objects["level_text"]
71
+#    level_text.resolution = 8
72
+    lastup = own["lastup"]
73
+    lastdown = own["lastdown"]
74
+    lastleft = own["lastleft"]
75
+    lastright = own["lastright"]    
76
+    lastpstate = own["lastpstate"]
77
+    playspeed = 2
78
+    #sSelect = cont.actuators["sSelect"]
79
+    cont.deactivate(own.actuators['restart'])                                        
80
+    #joy down
81
+#    if down == 1 and lastdown != 1:
82
+#        #own.stopAction(0)
83
+#        pstate = own["pstate"]
84
+#                    
85
+#        if pstate == 0 and submenu_on == 0:
86
+#            resume.playAction("p_resume", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
87
+#        if pstate == 1 and submenu_on == 0:
88
+#            settings.playAction("p_settings", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
89
+#        if pstate == 2 and submenu_on == 0:
90
+#            level.playAction("p_level", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
91
+#            #level.playAction("p_level_select", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
92
+#        if pstate == 3 and submenu_on == 0:
93
+#            restart.playAction("p_restart", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)
94
+#        if pstate == 4 and submenu_on == 0:
95
+#            exit.playAction("p_exit", 10,0, layer=1, priority=0, play_mode=0, speed=playspeed)           
96
+#            
97
+#        if pstate < 4 and submenu_on == 0:
98
+#            own["pstate"] = own["pstate"] + 1
99
+#        if pstate == 4 and submenu_on == 0:
100
+#            own["pstate"] = 0    
101
+#        pstate = own["pstate"]
102
+#        #print(pstate)   
103
+#        cont.activate(own.actuators['sSelect']) 
104
+#    #joy up    
105
+#    if up == 1 and lastup != 1:
106
+#        pstate = own["pstate"]
107
+#                    
108
+#        if pstate == 0 and submenu_on == 0:
109
+#            resume.playAction("p_resume", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
110
+#        if pstate == 1 and submenu_on == 0:
111
+#            settings.playAction("p_settings", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
112
+#        if pstate == 2 and submenu_on == 0:
113
+#            level.playAction("p_level", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
114
+#        if pstate == 3 and submenu_on == 0:
115
+#            restart.playAction("p_restart", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
116
+#        if pstate == 4 and submenu_on == 0:
117
+#            exit.playAction("p_exit", 10,0, layer=0, priority=0, play_mode=0, speed=playspeed)
118
+#            
119
+#            
120
+#        if pstate > 0 and submenu_on == 0:
121
+#            own["pstate"] = own["pstate"] - 1
122
+#        if pstate == 0 and submenu_on == 0:
123
+#            own["pstate"] = 4    
124
+#        pstate = own["pstate"]
125
+#        #print(pstate)    
126
+#        cont.activate(own.actuators['sSelect'])  
127
+#    if right == 1 and lastright !=1:
128
+#        cont.activate(own.actuators['sSelect']) 
129
+#    if left == 1 and lastleft != 1:    
130
+#        cont.activate(own.actuators['sSelect'])
131
+        
132
+#level*****************************************************
133
+
134
+#    if own["submenu"] == "level":
135
+#        #print("submenu is level")
136
+#        active_level_select = own["active_level_select"]
137
+#        
138
+#        import Settings
139
+#        if left == 1 and lastleft != 1:
140
+#            if active_level_select >= 0:
141
+#               active_level_select -= 1
142
+#            if active_level_select < 0:
143
+#                active_level_select = 8    
144
+#            #if active_level_select == -1:    
145
+#                #active_level_select = 0
146
+#        #print(active_level_select)        
147
+#            #move up
148
+#            #play up            
149
+#        if right == 1 and lastright != 1:    
150
+#            if active_level_select < 9:
151
+#               active_level_select += 1               
152
+#            if active_level_select == 9:
153
+#                active_level_select = 0
154
+#            if active_level_select == -1:    
155
+#                active_level_select = 0
156
+#        #print(active_level_select)                        
157
+#            #move down
158
+#            #play down
159
+#        if active_level_select == 0:
160
+#            level_text.text = "Empty Lot"
161
+#        if active_level_select == 1:
162
+#            level_text.text = "Waterfall"
163
+#        if active_level_select == 2:
164
+#            level_text.text = "Warehouse" 
165
+#        if active_level_select == 3:
166
+#            level_text.text = "City"          
167
+#        if active_level_select == 4:
168
+#            level_text.text = "Training"          
169
+#        if active_level_select == 5:
170
+#            level_text.text = "Spine" 
171
+#        if active_level_select == 6:
172
+#            level_text.text = "Apricot Park" 
173
+#        if active_level_select == 7:
174
+#            level_text.text = "Newday Bowl"                           
175
+#        if active_level_select == 8:
176
+#            level_text.text = "Garage 18"                                                                      
177
+#        own["active_level_select"] = active_level_select 
178
+#        load_timer = 100
179
+##indoor
180
+#        if aBut == False and active_level_select == 0 and lasta == 1:
181
+#            level_text.text = ""
182
+#            cont.activate(own.actuators['loading']) 
183
+#            level = "lot"
184
+#            main_empty["level"] = "lot"
185
+#            own["level"] = level
186
+#            Settings.writeSettings()
187
+#            #print("not")
188
+#            Settings.readSettings()
189
+#            #cont.activate(own.actuators['restart'])
190
+#            dict['reload_timer'] = 250
191
+#            dict['overlay_fadein'] = 1
192
+#            #Settings.loadlevel() 
193
+#            dict['load_timer'] = load_timer
194
+#        else: 
195
+#            
196
+#            cont.deactivate(own.actuators['restart']) 
197
+##woodbowl               
198
+#        if aBut == False and active_level_select == 1 and lasta == 1:
199
+#            level_text.text = ""
200
+#            #cont.activate(own.actuators['loading']) 
201
+#            level = "mini_scene"
202
+#            main_empty["level"] = "mini_scene"
203
+#            own["level"] = level
204
+#            Settings.writeSettings()
205
+#            Settings.readSettings()
206
+#            #cont.activate(own.actuators['restart']) 
207
+#            dict['reload_timer'] = 250
208
+#            dict['overlay_fadein'] = 1
209
+#            #Settings.loadlevel()
210
+#            dict['load_timer'] = load_timer
211
+#        else: cont.deactivate(own.actuators['restart']) 
212
+##mini        
213
+#        if aBut == False and active_level_select == 2 and lasta == 1:
214
+#            level_text.text = ""
215
+#            #cont.activate(own.actuators['loading']) 
216
+#            level = "warehouse"
217
+#            main_empty["level"] = "warehouse"
218
+#            own["level"] = level
219
+#            Settings.writeSettings()
220
+#            Settings.readSettings()
221
+#            #cont.activate(own.actuators['restart']) 
222
+#            dict['reload_timer'] = 250
223
+#            dict['overlay_fadein'] = 1
224
+#            #Settings.loadlevel()
225
+#            dict['load_timer'] = load_timer
226
+#        else: cont.deactivate(own.actuators['restart'])
227
+##level3        
228
+#        if aBut == False and active_level_select == 3 and lasta == 1:
229
+#            level_text.text = ""
230
+#            level = "city2"
231
+#            main_empty["level"] = "city2"
232
+#            own["level"] = level
233
+#            Settings.writeSettings()
234
+#            Settings.readSettings()
235
+#            #cont.activate(own.actuators['restart']) 
236
+#            dict['reload_timer'] = 250
237
+#            dict['overlay_fadein'] = 1
238
+#            #Settings.loadlevel()
239
+#            dict['load_timer'] = load_timer
240
+#        else: cont.deactivate(own.actuators['restart']) 
241
+##hubbas rail        
242
+#        if aBut == False and active_level_select == 4 and lasta == 1:
243
+#            level_text.text = ""
244
+#            level = "train"
245
+#            main_empty["level"] = "train"
246
+#            own["level"] = level
247
+#            Settings.writeSettings()
248
+#            Settings.readSettings()
249
+#            #cont.activate(own.actuators['restart']) 
250
+#            dict['reload_timer'] = 250
251
+#            dict['overlay_fadein'] = 1
252
+#            #Settings.loadlevel()
253
+#            dict['load_timer'] = load_timer
254
+#        else: cont.deactivate(own.actuators['restart']) 
255
+##training        
256
+#        if aBut == False and active_level_select == 5 and lasta == 1:
257
+#            level_text.text = ""
258
+#            level = "spine"
259
+#            main_empty["level"] = "spine"
260
+#            own["level"] = level
261
+#            Settings.writeSettings()
262
+#            Settings.readSettings()
263
+#            #cont.activate(own.actuators['restart']) 
264
+#            dict['reload_timer'] = 250
265
+#            dict['overlay_fadein'] = 1
266
+#            #Settings.loadlevel()
267
+#            dict['load_timer'] = load_timer
268
+#        else: cont.deactivate(own.actuators['restart'])  
269
+#        if aBut == False and active_level_select == 6 and lasta == 1:
270
+#            level_text.text = ""
271
+#            level = "gt"
272
+#            main_empty["level"] = "gt"
273
+#            own["level"] = level
274
+#            Settings.writeSettings()
275
+#            Settings.readSettings()
276
+#            #cont.activate(own.actuators['restart']) 
277
+#            dict['reload_timer'] = 250
278
+#            dict['overlay_fadein'] = 1
279
+#            #Settings.loadlevel()
280
+#            dict['load_timer'] = load_timer
281
+#        else: cont.deactivate(own.actuators['restart']) 
282
+#        if aBut == False and active_level_select == 7 and lasta == 1:
283
+#            level_text.text = ""
284
+#            level = "newday"
285
+#            main_empty["level"] = "newday"
286
+#            own["level"] = level
287
+#            Settings.writeSettings()
288
+#            Settings.readSettings()
289
+#            #cont.activate(own.actuators['restart']) 
290
+#            dict['reload_timer'] = 250
291
+#            dict['overlay_fadein'] = 1
292
+#            #Settings.loadlevel()
293
+#            dict['load_timer'] = load_timer
294
+#        else: cont.deactivate(own.actuators['restart']) 
295
+#        if aBut == False and active_level_select == 8 and lasta == 1:
296
+#            level_text.text = ""
297
+#            level = "garage18"
298
+#            main_empty["level"] = "garage18"
299
+#            own["level"] = level
300
+#            Settings.writeSettings()
301
+#            Settings.readSettings()
302
+#            #cont.activate(own.actuators['restart']) 
303
+#            #Settings.loadlevel()
304
+#            dict['load_timer'] = load_timer
305
+#            dict['reload_timer'] = 250
306
+#            dict['overlay_fadein'] = 1
307
+#        else: cont.deactivate(own.actuators['restart'])                                               
308
+#    else:
309
+#        own["active_level_select"] = -1 
310
+#    if bBut == True:    
311
+#        levelselect.playAction("p_level_select", 10,0, layer=3, priority=0, play_mode=0, speed=playspeed)                                         
312
+#**********************************************************   
313
+
314
+
315
+
316
+ 
317
+
318
+#    if pstate == 0 and submenu_on == 0 and lastpstate != 0:
319
+#        resume.playAction("p_resume", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
320
+#    if pstate == 1 and submenu_on == 0 and lastpstate != 1:
321
+#        settings.playAction("p_settings", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
322
+#    if pstate == 2 and submenu_on == 0 and lastpstate != 2:
323
+#        level.playAction("p_level", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
324
+#        #level.playAction("p_level_select", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
325
+#    if pstate == 3 and submenu_on == 0 and lastpstate != 3:
326
+#        restart.playAction("p_restart", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)
327
+#    if pstate == 4 and submenu_on == 0 and lastpstate != 4:
328
+#        exit.playAction("p_exit", -10,10, layer=0, priority=0, play_mode=0, speed=playspeed)                
329
+
330
+
331
+    #find the scene and object
332
+    scenes = bge.logic.getSceneList()
333
+    for scene in scenes :
334
+        #if scene.name == 'lot' or scene.name == 'train' or scene.name == 'mini_scene' or scene.name == 'city' or scene.name == 'city2' or scene.name == 'spine':
335
+        #if scene.name == main_empty["level"]: 
336
+        if scene.name == 'lot':    
337
+            #print("*****stop sounds")
338
+            cc = scene.objects['control_cube.002']
339
+            cc.actuators["sroll"].volume = .0001
340
+            #cc.deactivate(own.actuators["sroll"])
341
+            cc.actuators["sroll"].stopSound()            
342
+ 
343
+    #print(pstate) 
344
+    own["lastup"] = up
345
+    own["lastdown"] = down 
346
+    own["lastleft"] = left
347
+    own["lastright"] = right 
348
+    own["lasta"] = aBut 
349
+    own["lastpstate"] = own["pstate"]
350
+main()

+ 45
- 0
scripts/pause_menu2.py View File

1
+import bge
2
+
3
+
4
+def check_idle():
5
+    dict = bge.logic.globalDict
6
+    dict['menu_idle_timer'] +=1
7
+    idle = 0
8
+    if dict['aBut'] or dict['bBut'] or dict['xBut'] or dict['yBut'] or dict['ddPad'] or dict['udPad'] or dict['ldPad'] or dict['rdPad'] or (dict['lUD'] > .02 or dict['lUD'] < -.02) or (dict['lLR'] > .02 or dict['lLR'] < -.02) or (dict['rUD'] > .02 or dict['rUD'] < -.02) or (dict['rLR'] > .02 or dict['rLR'] < -.02):
9
+        dict['menu_idle_timer'] = 0
10
+    #print('idtime', dict['menu_idle_timer']) 
11
+    if dict['menu_idle_timer'] > 500:
12
+        idle =1
13
+    return idle                        
14
+
15
+def update_text(cont):
16
+    own = cont.owner
17
+    scene = bge.logic.getCurrentScene()
18
+    dict = bge.logic.globalDict
19
+    if dict['pause_menu_text'] == '':
20
+        scene.objects['menu_text'].text = 'menu > fuck' 
21
+    else:
22
+        if 'menu_text' in scene.objects: 
23
+            scene.objects['menu_text'].text = dict['pause_menu_text']   
24
+        if 'menu_text.001' in scene.objects: 
25
+            scene.objects['menu_text.001'].text = dict['pause_menu_text']               
26
+
27
+#    scene = bge.logic.getCurrentScene()
28
+    for object in scene.objects:
29
+        if isinstance(object, bge.types.KX_FontObject):
30
+            object.resolution = 16     
31
+                    
32
+    info = ('Music > ' + dict['mu_artist'] + ' - ' + dict['mu_title'])
33
+    #print(info)
34
+    try:
35
+        scene.objects['music_info_txt'].text = info                       
36
+    except:
37
+        pass    
38
+                    
39
+                    
40
+def main(cont):
41
+    update_text(cont)  
42
+    check_idle()      
43
+
44
+#active selection list        
45
+#selected_item_index

+ 170
- 0
scripts/scene_init.py View File

1
+import bge
2
+import colors
3
+
4
+def main():
5
+    import bge
6
+    #import GameLogic
7
+    cont = bge.logic.getCurrentController()
8
+    own = cont.owner
9
+    dict = bge.logic.globalDict
10
+    #print("nnnnnnpause level", dict['level'])
11
+    own['last_stBut'] = False
12
+    level = dict['level']
13
+    scene = bge.logic.getCurrentScene()
14
+    cam = scene.objects['Camera.003']
15
+    curscene = bge.logic.getCurrentScene()
16
+    
17
+#    scenes = bge.logic.getSceneList()
18
+#    for scene in scenes :
19
+#        if scene.name == 'main':
20
+#            player = scene.objects['player']    
21
+#    main = bge.logic.getSceneList["main"]
22
+
23
+    dict['overlay_fadeout'] = 1
24
+    scenes = bge.logic.getSceneList()
25
+    own['pre_pause_linvel'] = 0.0
26
+
27
+    objList = scene.objects
28
+
29
+    # get object named MainCharacter
30
+    parent = objList["control_cube.002"]
31
+
32
+    # combine child's shape with parent's
33
+    compound = True
34
+    obj = scene.objects['Char4']
35
+    # child is solid
36
+    ghost = False
37
+    # set parent
38
+    obj.setParent( parent, compound, ghost) 
39
+    parent.worldPosition.z += .5 
40
+  
41
+    scene.gravity = [0,0,dict['gravity']]    
42
+    for i in scenes:
43
+        if i.name == "main":
44
+            main = i
45
+    
46
+    for i in scenes:
47
+        if i.name == "fade_out":
48
+            print('ending fade_out', scenes)
49
+            scene2 = i
50
+            scene2.end()  
51
+               
52
+    
53
+    if level == 'newday':
54
+        brightness = 2.6
55
+        cam['BC_BRIGHTNESS'] = 1.3
56
+        cam['BC_CONTRAST'] = 1.5
57
+#    elif level == 'lot':
58
+#        brightness = 2.6
59
+#        cam['BC_BRIGHTNESS'] = 1
60
+#        cam['BC_CONTRAST'] = 1   
61
+#        #main.world.zenithColor = [1.0, .9, .975, 0]
62
+#        #main.world.horizonColor = [.42, .555, .823, 0] 
63
+#        curscene.world.zenithColor = [1.0, .9, .975, 0]
64
+#        curscene.world.horizonColor = [.42, .555, .823, 0]                 
65
+        #print("sadfasdfsdfasdfasdfasdfasdfasdf")
66
+    elif level == 'spine':
67
+        brightness = 2.6
68
+        cam['BC_BRIGHTNESS'] = .85
69
+        cam['BC_CONTRAST'] = 1.1  
70
+        
71
+    elif level == 'sc':
72
+        print('setting color of', curscene)
73
+        curscene.world.zenithColor = [.23, .23, .25, 1] #[0.1,.2,.4,.5]#[.58, .86, 1.0, 0] #[.3, 0.3, 0.3, 0]
74
+        curscene.world.horizonColor = [.1, .15, .3, 1] #[0.1,0,0,1] #[.58, .86, 1.0, 1]         
75
+        
76
+    elif level == 'garage18':
77
+        print('setting color of', curscene)
78
+        curscene.world.zenithColor = [0, 0.0, 0.0, 0]
79
+        curscene.world.horizonColor = [0, 0, 0.0, 0]   
80
+
81
+    elif level == 'pats':
82
+        print('setting color of', curscene)
83
+     
84
+    if dict['bc'] == 1:
85
+        cont.activate(cam.actuators["bc"])
86
+
87
+    else:
88
+        cont.activate(cam.actuators["bc_off"])  
89
+    if dict['hdr'] == 1:
90
+        cont.activate(cam.actuators["hdr"])
91
+
92
+    else:
93
+        cont.activate(cam.actuators["hdr_off"])
94
+                            
95
+    if dict['ao'] == 1:
96
+        cont.activate(cam.actuators["ao"])
97
+
98
+    else:
99
+        cont.activate(cam.actuators["ao_off"])                    
100
+
101
+    if dict['dof_on'] == 1:
102
+        cont.activate(cam.actuators["DOF"])
103
+
104
+    else:
105
+        cont.activate(cam.actuators["DOF_off"])
106
+        
107
+    if dict['bloom_on'] == 1:
108
+        cont.activate(cam.actuators["Bloom"])
109
+
110
+    else:
111
+        cont.activate(cam.actuators["bloom_off"])
112
+        
113
+#    print(dict['shadow_on'], 'shadow_on')    
114
+#    if dict['shadow_on'] == 1:
115
+#        bge.render.setGLSLMaterialSetting("shadows", 1) 
116
+#    else:
117
+#        bge.render.setGLSLMaterialSetting("shadows", 0)  
118
+
119
+    if dict['music_player'] == 1:
120
+        dict['music_start'] =  True   
121
+        print('starting music') 
122
+    else:
123
+        print('not starting music', dict['music_player'])        
124
+        
125
+    scene.world.envLightEnergy = dict['ambient_strength']   
126
+    
127
+    cam['BC_BRIGHTNESS'] = dict['BC_BRIGHTNESS'] 
128
+    cam['BC_CONTRAST'] = dict['BC_CONTRAST']
129
+    cam['bc'] = dict['bc']  
130
+    cam['hdr'] = dict['hdr']
131
+    cam['avgL'] = dict['avgL']
132
+    cam['HDRamount'] = dict['HDRamount']
133
+    cam['ao'] = dict['ao']  
134
+    cam['onlyAO'] = dict['onlyAO']
135
+    cam['aowidth'] = dict['aowidth']
136
+    cam['aoradius'] = dict['aoradius']  
137
+    cam['ambient_strength'] = dict['ambient_strength']
138
+    cam['sun_strength'] = dict['sun_strength']
139
+    cam['sun_pos_x'] = dict['sun_rot_x']
140
+    cam['sun_pos_y'] = dict['sun_rot_y']
141
+    #cam['shadow_on'] = dict['shadow_on']
142
+    cam['dof_on'] = dict['dof_on']
143
+    cam['bloom_on'] = dict['bloom_on'] 
144
+    cam['fxaa'] = dict['fxaa']
145
+    cam['FXAA_SPAN_MAX'] = dict['FXAA_SPAN_MAX']     
146
+    own['grindnew_timer'] = 0   
147
+    own['last_ramp'] = 0
148
+    own['requestAction'] = ''
149
+    own['l_actionState'] = ''
150
+    own['actionState'] = ''
151
+    own['transition_timer'] = 0
152
+    own['transitioning'] = 0
153
+    own['driving'] = False
154
+    dict['last_driving'] = False
155
+    own['last_roty'] = 0.0
156
+    
157
+    own['walk_targ_speed'] = 2
158
+    own['walk_fast_targ_speed'] = 5
159
+    own['walk_speed'] = 0
160
+    own['walk_inc'] = .05
161
+    own['walk_jump_timer'] = 0
162
+    own['no_grind_timer'] = 0
163
+    own['last_jump_frame'] = 0
164
+    
165
+    colors.update_shirt_tex() 
166
+    colors.update_truck_tex()
167
+    
168
+    print('scene init ran')
169
+      
170
+main()

+ 52
- 0
scripts/stance.py View File

1
+import bge
2
+from bge import logic
3
+cont = bge.logic.getCurrentController()
4
+own = cont.owner
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
+
18
+#constants
19
+STANCE_SENS = 0.05
20
+STANCE = own["stance"]
21
+jumpstance = own['jump_stance']
22
+grindpos = own['grindpos']
23
+# use game object axis
24
+local = True
25
+try:
26
+    #stance detection   
27
+    if own['ground'] == True and (own['grindpos'] != 'reg_board' or own['grindOld'] == False) and own['invert_on'] == False:
28
+        #print("detect stance") 
29
+        LVX = own.localLinearVelocity.x
30
+        if LVX > STANCE_SENS:
31
+            STANCE = 1
32
+            
33
+        if LVX < (-STANCE_SENS):
34
+            STANCE = 0
35
+except:
36
+    print("no stance")
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
45
+own["stance"] = STANCE           
46
+dict = bge.logic.globalDict #Get the global dictionary
47
+dict['stance'] = STANCE #Store the new score
48
+#print(STANCE)
49
+#stance = dict.get('stance') #Get the current score or the number 0
50
+#print(LVX)    
51
+#print(STANCE)
52
+

+ 95
- 0
scripts/trick_text.py View File

1
+import bge
2
+
3
+
4
+def main():
5
+
6
+    cont = bge.logic.getCurrentController()
7
+    own = cont.owner
8
+    dict = bge.logic.globalDict
9
+    trick_string = dict.get('trick_string')
10
+    #print(trick_string, "textstring")
11
+    print_text_timer = own['print_text_timer']
12
+    print_text_timer2 = own['print_text_timer2']
13
+    print_text_timer3 = own['print_text_timer3']
14
+    old_print_text = own['print_text']
15
+    old_print_text2 = own['print_text2']
16
+    old_print_text3 = own['print_text3']
17
+    print_text = ''
18
+    timer_length = 300
19
+    #set strings
20
+    show_tricks = 0
21
+    if show_tricks == 1:
22
+        if trick_string != None:
23
+            if old_print_text == '':
24
+            #if 1 == 1:    
25
+                own['print_text'] = trick_string
26
+                print_text_timer = timer_length
27
+                print_text = trick_string
28
+                own['print_text'] = print_text
29
+            elif old_print_text2 == '':
30
+                text = own['print_text']
31
+                text = '\n' + str(text)
32
+                own['print_text2'] = text
33
+                own['print_text'] = trick_string
34
+                print_text_timer2 = own['print_text_timer']
35
+                print_text_timer = timer_length
36
+                print_text = trick_string
37
+                own['print_text'] = print_text 
38
+            elif old_print_text3 == '':
39
+                own['print_text3'] = own['print_text2']
40
+                own['print_text2'] = own['print_text']
41
+                text = own['print_text']
42
+                text = '\n' + str(text)
43
+                own['print_text2'] = text
44
+                own['print_text'] = trick_string
45
+                print_text_timer3 = own['print_text_timer2']
46
+                print_text_timer2 = own['print_text_timer']
47
+                print_text_timer = timer_length
48
+                print_text = trick_string
49
+                own['print_text'] = print_text                
50
+            dict['trick_string'] = None
51
+
52
+    #read timers
53
+        #print("t1: ", print_text_timer, "t2: ", print_text_timer2)
54
+        if print_text_timer3 > 0:
55
+            print_text_timer3 = print_text_timer3 - 1
56
+            print_text3 = own['print_text3']
57
+            #own.text = (str(print_text) + str(print_text2))
58
+            own['print_text_timer3'] = print_text_timer3
59
+        if print_text_timer3 <=0:
60
+            print_text3 = ''
61
+            own['print_text_timer3'] = '' 
62
+            own['print_text3'] = '' 
63
+        if print_text_timer2 > 0:
64
+            print_text_timer2 = print_text_timer2 - 1
65
+            print_text2 = own['print_text2']
66
+            #own.text = (str(print_text) + str(print_text2))
67
+            own['print_text_timer2'] = print_text_timer2
68
+        if print_text_timer2 <=0:
69
+            print_text2 = ''
70
+            own['print_text_timer2'] = '' 
71
+            own['print_text2'] = ''    
72
+        if print_text_timer > 0:
73
+            print_text_timer = print_text_timer - 1
74
+            print_text = own['print_text']
75
+            #own.text = str(print_text)
76
+            own['print_text_timer'] = print_text_timer
77
+            #print("print text is: ", print_text)
78
+        if print_text_timer <= 0:
79
+            own.text = ''
80
+            own['print_text'] = ''   
81
+            own['print_text_timer'] = print_text_timer 
82
+    #        own['print_text_timer3'] = print_text_timer3 
83
+    #        own['print_text_timer2'] = print_text_timer2    
84
+        dict['last_trick_string'] = dict.get('trick_string')
85
+        print_text_timer = own['print_text_timer']
86
+        old_print_text = own['print_text']
87
+        old_print_text2 = own['print_text2']
88
+        old_print_text3 = own['print_text3']
89
+        output_text = str(old_print_text) + str(old_print_text2) + str(old_print_text3) 
90
+        own.text = output_text
91
+    #print("1: ", old_print_text, "2: ", old_print_text2, "3: ", old_print_text3)    
92
+    #print(print_text_timer, " : timer")
93
+    else:
94
+        own.text = ''
95
+main()

+ 1258
- 0
scripts/walk.py View File

1
+#shuvit.org
2
+#walk.py
3
+
4
+import bge
5
+import GameLogic
6
+import ctypes
7
+import random
8
+import math
9
+
10
+scene = bge.logic.getCurrentScene()
11
+objList = scene.objects
12
+
13
+cont = GameLogic.getCurrentController() 
14
+obj = bge.logic.getCurrentScene().objects
15
+char = bge.constraints.getCharacter
16
+own = cont.owner
17
+stance = own['stance']
18
+STANCE = own['stance']
19
+r_ground = cont.sensors["r_Ground"]
20
+linvel = own.getLinearVelocity(True)
21
+lasta = own['lasta']
22
+lastx = own['lastx']
23
+last_sit = own['sit']
24
+dict = bge.logic.globalDict
25
+
26
+try:
27
+    own['walk_timer'] = own['walk_timer'] +1
28
+except:
29
+    own['walk_timer'] = 1
30
+    own['walk_targ_speed'] = 2.0
31
+
32
+truckon = 450
33
+deckon = 460
34
+
35
+lLR = dict['lLR']
36
+lUD = dict['lUD']
37
+rLR = dict['rLR']
38
+rUD = dict['rUD']
39
+lTrig = dict['lTrig']
40
+rTrig = dict['rTrig']
41
+aBut = dict['aBut']
42
+bBut = dict['bBut']
43
+xBut = dict['xBut']
44
+yBut = dict['yBut']
45
+lBump = dict['lBump']
46
+rBump = dict['rBump']
47
+bkBut = dict['bkBut']
48
+stBut = dict['stBut']
49
+xbBut = dict['xbBut']
50
+ltsBut = dict['ltsBut']
51
+rtsBut = dict['rtsBut']
52
+ldPad = dict['ldPad']
53
+rdPad = dict['rdPad']
54
+udPad = dict['udPad']
55
+ddPad = dict['ddPad']
56
+
57
+#user
58
+sens = .04
59
+fliplay = 30
60
+dropinCol = own.sensors['dropinCol']
61
+cube = scene.objects['control_cube.002']
62
+skater = scene.objects["Char4"]
63
+deck = scene.objects["deck"]
64
+trucks = scene.objects["trucks"]
65
+camobj2 = scene.objects['camobj']
66
+throw_deck_empty = scene.objects["throw_deck_empty"]
67
+wheel1 = scene.objects["rollen.000"]
68
+wheel2 = scene.objects["rollen.001"]
69
+wheel3 = scene.objects["rollen.002"]
70
+wheel4 = scene.objects["rollen.003"]
71
+camobj = scene.objects["Camera.003"]
72
+camera = cont.actuators["Camera"]
73
+replayCam = cont.actuators["replayCam"]
74
+timer = own['dropinTimer']
75
+cam = scene.objects["Camera.003"]
76
+freecam = scene.objects["freecam"]
77
+followcam = scene.objects["followcam"]
78
+
79
+control_bottom = scene.objects['control_bottom']
80
+cb = control_bottom.sensors['grindCol_bottom']
81
+cb_td = control_bottom.sensors['td_bottom']
82
+
83
+noidle = 0
84
+
85
+#if skater.isPlayingAction(460):  
86
+#    noidle = 1  
87
+try:
88
+    walk_inc = own['walk_inc'] 
89
+except:
90
+    own['walk_inc'] = .01
91
+    walk_inc = own['walk_inc']  
92
+    own['walk_jump_timer'] = 0   
93
+if own['stair_counter'] != 0:
94
+    walk_inc = own['walk_inc']  *10
95
+
96
+if own["stance"] == None:
97
+    own["stance"] = True
98
+STANCE = own["stance"]
99
+def killact(layer):
100
+    if skater.isPlayingAction(layer):
101
+        skater.stopAction(layer)
102
+    if deck.isPlayingAction(layer):    
103
+        deck.stopAction(layer)
104
+    if trucks.isPlayingAction(layer):    
105
+        trucks.stopAction(layer)
106
+def killall():
107
+    for x in range(5000):
108
+        skater.stopAction(x)
109
+        deck.stopAction(x)
110
+        trucks.stopAction(x)
111
+def trucksisplaying():
112
+    for x in range(5000):
113
+        if deck.isPlayingAction(x):
114
+            print("deck is playing:", x)
115
+
116
+def printplaying():
117
+    splaying_layers = "S: "
118
+    playing_layers = "D: "
119
+    tplaying_layers = "T: "
120
+    for x in range(9900):
121
+        if skater.isPlayingAction(x):
122
+        #if trucks.isPlayingAction(x):
123
+        #if skater.isPlayingAction(x):                        
124
+            splaying_layers += str(x)
125
+            splaying_layers += " "        
126
+        if deck.isPlayingAction(x):
127
+        #if trucks.isPlayingAction(x):
128
+        #if skater.isPlayingAction(x):                        
129
+            playing_layers += str(x)
130
+            playing_layers += " "
131
+        if trucks.isPlayingAction(x):
132
+        #if trucks.isPlayingAction(x):
133
+        #if skater.isPlayingAction(x):                        
134
+            tplaying_layers += str(x)
135
+            tplaying_layers += " "            
136
+    print(splaying_layers, playing_layers, tplaying_layers) 
137
+#printplaying() 
138
+##
139
+if r_ground.positive and xBut == False and lastx == False:
140
+    killact(10)
141
+    #killact(11)
142
+    killact(12)
143
+    killact(13)              
144
+######################################    
145
+
146
+#idle      
147
+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:
148
+    own['requestAction'] = 'reg_idle'
149
+    if own['throw_deck'] == True:
150
+        own['requestAction'] = 'reg_idle_nb'
151
+
152
+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:
153
+    own['requestAction'] = 'fak_idle'
154
+    if own['throw_deck'] == True:
155
+        own['requestAction'] = 'fak_idle_nb'
156
+
157
+if lUD < -sens:
158
+    lup = 1
159
+else:
160
+    lup = 0
161
+if lUD > sens:
162
+    ldown = 1
163
+else:
164
+    ldown = 0 
165
+if lLR < -sens:
166
+    lLeft = 1
167
+else:
168
+    lLeft = 0
169
+if lLR > sens:
170
+    lRight = 1
171
+else:
172
+    lRight = 0        
173
+
174
+
175
+
176
+#turning
177
+turning = False
178
+if r_ground.positive:
179
+    num = .5
180
+    tilt = .015
181
+    if STANCE == 1:
182
+        num *= -1
183
+        tilt *= -1
184
+    if lRight == 1 or dict['kb_ra'] == 2:
185
+        #cont.activate(own.actuators['right'])
186
+        own.linearVelocity.y = num
187
+        if own['stair_counter'] > 0:
188
+            if STANCE == 0:
189
+                own.applyRotation([0,0,.05], True)
190
+            else:
191
+                own.applyRotation([0,0,-.05], True)                
192
+        else:
193
+            own.applyRotation([-tilt, 0, 0], True)
194
+        turning = True
195
+    else:
196
+        #cont.deactivate(own.actuators['right']) 
197
+        pass  
198
+        
199
+    if lLeft == 1 or dict['kb_la'] == 2:
200
+        #cont.activate(own.actuators['left']) 
201
+        own.linearVelocity.y = -num
202
+        if own['stair_counter'] > 0:
203
+            if STANCE == 0:
204
+                own.applyRotation([0,0,.05], True)
205
+            else:
206
+                own.applyRotation([0,0,-.05], True)                                
207
+        else:        
208
+            own.applyRotation([tilt, 0, 0], True)        
209
+        turning = True
210
+    else:
211
+        #cont.deactivate(own.actuators['left'])        
212
+        pass
213
+
214
+#in air        
215
+#if (lup == 1 or dict['kb_ua'] != 0) and r_ground.positive == False:
216
+if r_ground.positive == False:
217
+    airrot = .05
218
+    if lLeft == 1 or dict['kb_la'] == 2:
219
+        if stance == 0:
220
+            own.applyRotation([0,0,airrot], True)
221
+        if stance == 1:    
222
+            own.applyRotation([0,0,airrot], True)
223
+    if lRight == 1 or dict['kb_ra'] == 2:
224
+        if stance == 0:
225
+            own.applyRotation([0,0,-airrot], True)
226
+        if stance == 1:    
227
+            own.applyRotation([0,0,-airrot], True)  
228
+            
229
+    if lup == 1 or dict['kb_ua'] == 2:
230
+        if own.linearVelocity.x < 10 and own .linearVelocity.x > - 10:
231
+            if stance == 0:
232
+                own.linearVelocity.x -= .04
233
+            if stance == 1:
234
+                own.linearVelocity.x += .04                             
235
+    own['lF_air_frame'] = own['framenum']  
236
+    own.actuators["walkondirt"].stopSound()
237
+
238
+    
239
+#walking
240
+
241
+#new walking
242
+vel = own.getLinearVelocity(True)
243
+if own['walk_timer'] < 50:
244
+    velx = vel.x * .95             
245
+    own.setLinearVelocity([velx, 0, vel.z], True)
246
+    #print('y is zero')
247
+else:
248
+    pass
249
+    #own.setLinearVelocity([0, 0, vel.z], True)
250
+    
251
+wf = 1
252
+if own['last_walk_frame'] - own['last_roll_frame'] > 55:
253
+    wf = 0   
254
+   
255
+if ((lup == 1 and aBut == 0) or (dict['kb_ua'] == 2 and dict['kb_lsh'] == 0)) and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0 and wf == 0 and dict['kb_space'] == 0:
256
+    own['walking'] = "regular"
257
+    walking = "regular"
258
+    
259
+elif ((lup == 1 and aBut == 1) or (dict['kb_lsh'] == 2 and dict['kb_ua'] == 2)) and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0 and wf == 0 and dict['kb_space'] != 2:
260
+    own['walking'] = "fast"
261
+    walking = "fast"
262
+else:
263
+    own['walking'] = None
264
+    walking = None
265
+   
266
+if walking == "regular":  
267
+    if stance == 1:
268
+        if linvel.x < own['walk_targ_speed']:
269
+            own.linearVelocity.x = linvel.x + walk_inc
270
+        else:
271
+            own.linearVelocity.x = own['walk_targ_speed']    
272
+    else:
273
+        if linvel.x > -own['walk_targ_speed']:
274
+            own.linearVelocity.x = linvel.x - walk_inc       
275
+        else:
276
+            own.linearVelocity.x = -own['walk_targ_speed']                
277
+if walking == "fast":   
278
+    if stance == 1:
279
+        if linvel.x < own['walk_fast_targ_speed']:
280
+            own.linearVelocity.x = linvel.x + walk_inc
281
+        else:
282
+            own.linearVelocity.x = own['walk_fast_targ_speed']  
283
+    else:
284
+        if linvel.x > -own['walk_fast_targ_speed']:
285
+            own.linearVelocity.x = linvel.x - walk_inc      
286
+        else:
287
+            own.linearVelocity.x = -own['walk_fast_targ_speed'] 
288
+
289
+if walking == None and r_ground.positive and own['walk_jump_timer'] == 0:      
290
+    if own['walk_timer'] < 50 and turning == False:
291
+        velx = vel.x * .95             
292
+        own.setLinearVelocity([velx, 0, vel.z], True)
293
+    elif own['walk_timer'] > 50:
294
+        if own.linearVelocity.x > .1 or own.linearVelocity.x < -.1:
295
+            own.linearVelocity.x *= .01
296
+        else:
297
+            own.linearVelocity.x = 0
298
+        if turning == False:    
299
+            if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01:
300
+                own.linearVelocity.y *= .01
301
+            else:
302
+                own.linearVelocity.y = 0                
303
+        #own.setLinearVelocity([0, 0, vel.z], True) 
304
+    
305
+#old walking
306
+if ((lup == 1 and aBut == 0) or (dict['kb_ua'] == 2 and dict['kb_lsh'] == 0)  and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0) or (turning == True and aBut == 0):
307
+    own.actuators["walkondirt"].volume = .2
308
+    own.actuators["walkondirt"].pitch = 1
309
+    cont.activate(own.actuators["walkondirt"])          
310
+    if stance == 0 and skater.isPlayingAction(fliplay) == False:             
311
+        #without deck
312
+        if own['throw_deck'] == True:
313
+            own['requestAction'] = 'reg_walk_nb'
314
+        else:
315
+            own['requestAction'] = 'reg_walk'
316
+               
317
+    if stance == 1 and skater.isPlayingAction(fliplay) == False:        
318
+        #without deck
319
+        if own['throw_deck'] == True:
320
+            own['requestAction'] = 'fak_walk_nb'
321
+        else:
322
+            own['requestAction'] = 'fak_walk'
323
+       
324
+elif (((lup == 1 and aBut == 1) or (dict['kb_lsh'] == 2 and dict['kb_ua'] == 2)) and yBut == False and (r_ground.positive or own['stair_counter'] > 0) and xBut == 0) or (turning == True and aBut == 1):
325
+    own.actuators["walkondirt"].volume = .2
326
+    own.actuators["walkondirt"].pitch = 1.3
327
+    cont.activate(own.actuators["walkondirt"])
328
+    #print('fastwalk')
329
+    if stance == 0 and skater.isPlayingAction(fliplay) == False:        
330
+        if own['throw_deck'] == True:
331
+            own['requestAction'] = 'reg_walkFast_nb'
332
+        else:
333
+            own['requestAction'] = 'reg_walkFast'
334
+         
335
+    if stance == 1 and skater.isPlayingAction(fliplay) == False:        
336
+        if own['throw_deck'] == True:
337
+            own['requestAction'] = 'fak_walkFast_nb'          
338
+        else:
339
+            own['requestAction'] = 'fak_walkFast'             
340
+else:
341
+    vel = own.getLinearVelocity(True)
342
+    cont.deactivate(own.actuators["walkondirt"])       
343
+
344
+       
345
+#---------------
346
+if rLR > .05:
347
+    cont.activate(camobj.actuators['camRight'])
348
+else:
349
+    cont.deactivate(camobj.actuators['camRight'])    
350
+if rLR < -.05:
351
+    cont.activate(camobj.actuators['camLeft'])
352
+else:
353
+    cont.deactivate(camobj.actuators['camLeft'])     
354
+if rUD > .05:
355
+    cont.activate(camobj.actuators['camDown'])
356
+else:
357
+    cont.deactivate(camobj.actuators['camDown'])     
358
+if rUD < -.05:
359
+    cont.activate(camobj.actuators['camUp'])
360
+else:
361
+    cont.deactivate(camobj.actuators['camUp'])     
362
+                
363
+#----------------
364
+#camera.height = .01 #.9
365
+#camera.min = 1.75
366
+#camera.max = 2.25
367
+lasty = own['lasty']     
368
+
369
+def onboard():
370
+    if own['walk'] == 0:
371
+        #print("start walking")
372
+        own['walk_idling'] = 0
373
+        if own['framenum'] > 100 and own['fall'] == False:
374
+            cont.activate(own.actuators['pop'])
375
+        own['getoffboard'] = False
376
+        own["walk_idle_frame"] = own["framenum"]
377
+        own['grindcement_vol'] = 0
378
+        own['grindcement_pitch'] = 0
379
+        own['grindrail_vol'] = 0
380
+        own['grindrail_pitch'] = 0 
381
+        own['sroll_vol'] = 0
382
+        own['sroll_pitch'] = 0   
383
+        
384
+        #camobj.worldPosition.z += 4              
385
+        try:
386
+            vel = own['offboard_vel']
387
+            vel = [velx, vel.y, vel.z]           
388
+        except: 
389
+            pass
390
+         
391
+        if STANCE == 0:
392
+            own['requestAction'] = 'reg_offboard'             
393
+            
394
+        if STANCE == 1:
395
+            own['requestAction'] = 'fak_offboard'                          
396
+def jump():
397
+    #limit fall speed
398
+    if linvel.z < -10:
399
+        own.linearVelocity.z = -10
400
+    if xBut == True or dict['kb_space'] == 1: 
401
+        if own['lastx'] == 0:
402
+            #killact(3)
403
+            #killact(4)
404
+            #killact(5)
405
+            #killact(6)
406
+            #killact(7)      
407
+            if STANCE == 0:  
408
+                own['requestAction'] ='reg_jump'  
409
+                #print('jump') 
410
+            if STANCE == 1:
411
+                own['requestAction'] ='fak_jump'             
412
+                #print('jump')
413
+            JUMPHEIGHT = 1100
414
+            force = [ 0.0, 0.0, JUMPHEIGHT]
415
+            # use local axis
416
+            local = False
417
+            # apply force -- limit jump speed
418
+            if linvel.z < 10:
419
+                #own.applyForce(force, local)
420
+                own.linearVelocity.z += 5
421
+                own.linearVelocity.x = linvel.x
422
+                own.linearVelocity.y = linvel.y
423
+                own['walk_jump_timer'] = 20
424
+        own['lastx'] = 1
425
+    else:
426
+        own['lastx'] = 0
427
+def dropin():
428
+    if dropinCol.positive == True:
429
+        pass       
430
+        
431
+def getonboard(dict):
432
+    #print(dict['kb_q'])
433
+    getonboard = own['getonboard']
434
+    fliplay2 = 50#8560
435
+    if ((yBut == True and dict['last_yBut'] == False) or dict['kb_q'] == 2):# and (cont.sensors["vehicleNear"].positive == False and own['throw_deck'] == False):
436
+        fliplay3 = fliplay2 + 1 
437
+        if dropinCol.positive == True: 
438
+            nearestObject = None
439
+            grindEmpty = scene.objects['grindEmpty']
440
+            grindDar = grindEmpty.sensors['grindDar2']
441
+            minDist = None             
442
+            if grindDar.positive:
443
+                detectedObjects = grindDar.hitObjectList
444
+                dist = 0
445
+                for obj in detectedObjects:
446
+                    dist = own.getDistanceTo(obj)
447
+                    if (minDist is None or dist < minDist):
448
+                        nearestObject = obj
449
+                        minDist = dist
450
+            if nearestObject != None:
451
+                #print(nearestObject)
452
+                obj = nearestObject
453
+                player_e = own.worldOrientation.to_euler()
454
+                player_pos = own.worldPosition
455
+                player_rotz = math.degrees(player_e[2])                
456
+                grinder_e = obj.worldOrientation.to_euler()
457
+                grinder_rotz = math.degrees(grinder_e[2])            
458
+                rot = player_rotz - grinder_rotz  
459
+                grinder_pos = obj.worldPosition 
460
+                worldVect = [1, 0, 0]
461
+                vect = obj.getAxisVect(worldVect)      
462
+                go = obj.worldOrientation
463
+                grinder_axis = [1,0,0] 
464
+                try: 
465
+                    delta = player_pos - grinder_pos
466
+                    
467
+                    delta = delta.cross(vect)
468
+                    if delta[2] >= 0:
469
+                        grindside = "right"
470
+                    else:
471
+                        grindside = "left"                    
472
+                    deltamove = delta[2] * .1#.25
473
+                    if STANCE == 0:
474
+                        move = [-deltamove, 0, 0]
475
+                    else:
476
+                        move = [deltamove, 0, 0]                            
477
+                    own.applyMovement(move, True)                    
478
+                except:
479
+                    pass 
480
+
481
+            if STANCE == 0: 
482
+                own['requestAction'] ='reg_dropin_pos' 
483
+                own['dropinTimer'] = 60                                     
484
+                    
485
+            if STANCE == 1: 
486
+                own['requestAction'] ='fak_dropin_pos'  
487
+                own['dropinTimer'] = 60                                 
488
+                                     
489
+    if getonboard == 1:
490
+        fliplay3 = 6000 
491
+        onboard_speed = .1                                      
492
+        own['getonboard'] = 0 
493
+        own['walk_idling'] = 0
494
+    if (yBut == False and lasty == True) or (yBut == True or dict['kb_q'] == 2) and dropinCol.positive:
495
+        deckact = deck.actuators["Visibility"]
496
+        trucksact = trucks.actuators["Visibility"]
497
+        wheel1act = wheel1.actuators["Visibility"]
498
+        wheel2act = wheel2.actuators["Visibility"]
499
+        wheel3act = wheel3.actuators["Visibility"]
500
+        wheel4act = wheel4.actuators["Visibility"]        
501
+        deckact.visibility = True
502
+        trucksact.visibility = True
503
+        wheel1act.visibility = True
504
+        wheel2act.visibility = True
505
+        wheel3act.visibility = True
506
+        wheel4act.visibility = True  
507
+        cont.activate(deck.actuators['Visibility'])
508
+        cont.activate(trucks.actuators['Visibility'])
509
+        cont.activate(wheel1.actuators['Visibility'])
510
+        cont.activate(wheel2.actuators['Visibility'])
511
+        cont.activate(wheel3.actuators['Visibility'])
512
+        cont.activate(wheel4.actuators['Visibility']) 
513
+        own['throw_deck'] = False 
514
+        throw_deck_empty = scene.objects["throw_deck_empty"]
515
+        throw_deck_empty['kill_deck'] = 1 
516
+    if ((yBut == False and lasty == True) or dict['kb_q'] == 3):# and cont.sensors["vehicleNear"].positive == False:               
517
+        own['getonboard'] = 1 
518
+        own['walk_idling'] = 0      
519
+
520
+def nextframe():
521
+    framenumber = own["framenum"]
522
+    framenumber = framenumber + 1
523
+    if framenumber == 900000:
524
+        framenumber = 0
525
+    own["framenum"] = framenumber
526
+    own['last_walk_frame'] = framenumber
527
+            
528
+def checkidle():
529
+    idle = cont.sensors["idle"]
530
+    idle_frame = own["walk_idle_frame"]
531
+    if idle.positive:
532
+        own["walk_idle_frame"] = 0
533
+        cont.deactivate(camobj.actuators['idle_camRight'])  
534
+        #camera.height = .5
535
+        camera.height = dict['cam_idle_height']
536
+    else: 
537
+        if idle_frame == 0:
538
+            own["walk_idle_frame"] = own["framenum"] 
539
+        diff = own["framenum"] - idle_frame
540
+        
541
+        if (diff > 700 and idle_frame != 0 and dropinCol.positive == False and own['walk'] != 0) or own['sit'] == 1:
542
+            cont.activate(camobj.actuators['idle_camRight'])  
543
+            #camera.height = .9   
544
+            #camera.min = 2
545
+            #camera.max = 2.50
546
+            own['walk_idling'] = 1
547
+        else:
548
+            own['walk_idling'] = 0    
549
+            
550
+def idle_anim():
551
+    if own['walk_idling'] == 1 and own['sit'] == 0:
552
+        walk_idle_frame = own['walk_idle_frame']
553
+        mod_num = (own["framenum"] - walk_idle_frame) % 240
554
+        idle_lay = 300
555
+        if mod_num == 0:
556
+            if own['idle_skipper'] > 0:
557
+               own['idle_skipper'] -= 1 
558
+            ran_num = random.randint(1, 8)
559
+            if own['last_idle_num'] == ran_num:
560
+                ran_num = 1
561
+            if own['idle_skipper'] == 0:
562
+                own['last_idle_num'] = ran_num
563
+                if ran_num == 1 or ran_num > 7:    
564
+                    killact(3)
565
+                    if STANCE == 0 and own['throw_deck'] == 0:
566
+                        own['requestAction'] = 'reg_idle1'
567
+                    elif STANCE == 0 and own['throw_deck'] == 1:
568
+                        own['requestAction'] = 'reg_idle1'
569
+                    elif STANCE == 1 and own['throw_deck'] == 0:
570
+                        own['requestAction'] = 'fak_idle1'
571
+                    elif STANCE == 1 and own['throw_deck'] == 1:
572
+                        own['requestAction'] = 'fak_idle1'
573
+                                                                           
574
+                elif ran_num == 2:    
575
+                    killact(3)
576
+                    if STANCE == 0 and own['throw_deck'] == 0:
577
+                        own['requestAction'] = 'reg_idle2'
578
+                    elif STANCE == 0 and own['throw_deck'] == 1:
579
+                        own['requestAction'] = 'reg_idle2_nb'
580
+                    elif STANCE == 1 and own['throw_deck'] == 0:
581
+                        own['requestAction'] = 'fak_idle1'
582
+                    elif STANCE == 1 and own['throw_deck'] == 1:
583
+                        own['requestAction'] = 'fak_idle1'
584
+                elif ran_num == 3:    
585
+                    killact(3)
586
+                    if STANCE == 0 and own['throw_deck'] == 0:
587
+                        own['requestAction'] = 'reg_idle3'
588
+                    elif STANCE == 0 and own['throw_deck'] == 1:
589
+                        own['requestAction'] = 'reg_idle3'
590
+                    elif STANCE == 1 and own['throw_deck'] == 0:
591
+                        own['requestAction'] = 'fak_idle1'
592
+                    elif STANCE == 1 and own['throw_deck'] == 1:
593
+                        own['requestAction'] = 'fak_idle1'
594
+                    own['idle_skipper'] = 2 
595
+                elif ran_num == 4:    
596
+                    killact(3)
597
+                    if STANCE == 0 and own['throw_deck'] == 0:
598
+                        own['requestAction'] = 'reg_idle4'
599
+                    elif STANCE == 0 and own['throw_deck'] == 1:
600
+                        own['requestAction'] = 'reg_idle4'
601
+                    elif STANCE == 1 and own['throw_deck'] == 0:
602
+                        own['requestAction'] = 'fak_idle4'
603
+                    elif STANCE == 1 and own['throw_deck'] == 1:
604
+                        own['requestAction'] = 'fak_idle4' 
605
+                elif ran_num == 5:    
606
+                    killact(3)
607
+                    if STANCE == 0 and own['throw_deck'] == 0:
608
+                        own['requestAction'] = 'reg_idle5'
609
+                    elif STANCE == 0 and own['throw_deck'] == 1:
610
+                        own['requestAction'] = 'reg_idle5'
611
+                    elif STANCE == 1 and own['throw_deck'] == 0:
612
+                        own['requestAction'] = 'fak_idle5'
613
+                    elif STANCE == 1 and own['throw_deck'] == 1:
614
+                        own['requestAction'] = 'fak_idle5'
615
+                elif ran_num == 6:    
616
+                    killact(3)
617
+                    if STANCE == 0 and own['throw_deck'] == 0:
618
+                        own['requestAction'] = 'reg_idle6'
619
+                    elif STANCE == 0 and own['throw_deck'] == 1:
620
+                        own['requestAction'] = 'reg_idle6'
621
+                    elif STANCE == 1 and own['throw_deck'] == 0:
622
+                        own['requestAction'] = 'fak_idle6'
623
+                    elif STANCE == 1 and own['throw_deck'] == 1:
624
+                        own['requestAction'] = 'fak_idle6'
625
+                elif ran_num == 7:    
626
+                    killact(3)
627
+                    if STANCE == 0 and own['throw_deck'] == 0:
628
+                        own['requestAction'] = 'reg_idle7'
629
+                    elif STANCE == 0 and own['throw_deck'] == 1:
630
+                        own['requestAction'] = 'reg_idle7'
631
+                    elif STANCE == 1 and own['throw_deck'] == 0:
632
+                        own['requestAction'] = 'fak_idle6'
633
+                    elif STANCE == 1 and own['throw_deck'] == 1:
634
+                        own['requestAction'] = 'fak_idle6'
635
+
636
+def reset_pos():
637
+    #reset
638
+    if ddPad == 1:   
639
+        spawn_pos = own['spawn_pos']
640
+        spawn_rot = own['spawn_rot']
641
+        spawn_cam_pos = own['spawn_cam_pos']
642
+        spawn_cam_rot = own['spawn_cam_rot']            
643
+        try:
644
+            own.worldPosition = (spawn_pos[0], spawn_pos[1], (spawn_pos[2] + .1))
645
+            own.worldOrientation = [[spawn_rot[0][0],spawn_rot[0][1],spawn_rot[0][2]], [spawn_rot[1][0],spawn_rot[1][1],spawn_rot[1][2]], [0.0, 0.0, 1.0]]
646
+            cam.worldPosition = (spawn_cam_pos[0], spawn_cam_pos[1], (spawn_cam_pos[2]))
647
+            cam.worldOrientation = [[spawn_cam_rot[0][0],spawn_cam_rot[0][1],spawn_cam_rot[0][2]], [spawn_cam_rot[1][0],spawn_cam_rot[1][1],spawn_cam_rot[1][2]], [0.0, 0.0, 1.0]]            
648
+        except:    
649
+            own.worldPosition = (0, 0, .1)
650
+            own.worldOrientation = [[1.0, 0.0, 0.0], [ 0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] 
651
+        own['stance'] = own['spawn_stance']                          
652
+        if own["spawn_stance"] == 1:
653
+            own.setLinearVelocity([.1,0,0], 1)
654
+        else: 
655
+            own.setLinearVelocity([-.1,0,0], 1)         
656
+            
657
+    if udPad == 1:        
658
+        own['spawn_pos'] = [own.worldPosition[0], own.worldPosition[1], own.worldPosition[2]] 
659
+        own['spawn_rot'] = [[own.worldOrientation[0][0],own.worldOrientation[0][1],own.worldOrientation[0][2]], [own.worldOrientation[1][0],own.worldOrientation[1][1],own.worldOrientation[1][2]], own.worldOrientation[2][2]]
660
+        own['spawn_cam_pos'] = [cam.worldPosition[0], cam.worldPosition[1], cam.worldPosition[2]] 
661
+        own['spawn_cam_rot'] = [[cam.worldOrientation[0][0],cam.worldOrientation[0][1],cam.worldOrientation[0][2]], [cam.worldOrientation[1][0],cam.worldOrientation[1][1],cam.worldOrientation[1][2]], cam.worldOrientation[2][2]]            
662
+        stance = own["stance"]
663
+        own["spawn_stance"] = stance   
664
+def falldeck():
665
+    throw_deck_empty = scene.objects["throw_deck_empty"]
666
+    deckact = deck.actuators["Visibility"]
667
+    trucksact = trucks.actuators["Visibility"]
668
+    wheel1act = wheel1.actuators["Visibility"]
669
+    wheel2act = wheel2.actuators["Visibility"]
670
+    wheel3act = wheel3.actuators["Visibility"]
671
+    wheel4act = wheel4.actuators["Visibility"]
672
+            
673
+    if own['throw_deck'] == False:
674
+        own['throw_deck'] = True
675
+        deckact.visibility = False
676
+        trucksact.visibility = False
677
+        wheel1act.visibility = False
678
+        wheel2act.visibility = False
679
+        wheel3act.visibility = False
680
+        wheel4act.visibility = False
681
+        act = throw_deck_empty.actuators['throw_dec_act']
682
+        if STANCE == True:
683
+            act.linearVelocity = [0.0, 1.0, 1.0]
684
+        if STANCE == False:
685
+            act.linearVelocity = [0.0, 1.0, -1.0]  
686
+        cont.activate(act)
687
+    else:
688
+        own['throw_deck'] = False    
689
+        deckact.visibility = True
690
+        trucksact.visibility = True
691
+        wheel1act.visibility = True
692
+        wheel2act.visibility = True
693
+        wheel3act.visibility = True
694
+        wheel4act.visibility = True
695
+        throw_deck_empty['kill_deck'] = 1    
696
+    cont.activate(deck.actuators['Visibility'])
697
+    cont.activate(trucks.actuators['Visibility'])
698
+    cont.activate(wheel1.actuators['Visibility'])
699
+    cont.activate(wheel2.actuators['Visibility'])
700
+    cont.activate(wheel3.actuators['Visibility'])
701
+    cont.activate(wheel4.actuators['Visibility']) 
702
+
703
+def throwdeck(strength, ud):
704
+    throw_deck_empty = scene.objects["throw_deck_empty"]
705
+    deckact = deck.actuators["Visibility"]
706
+    trucksact = trucks.actuators["Visibility"]
707
+    wheel1act = wheel1.actuators["Visibility"]
708
+    wheel2act = wheel2.actuators["Visibility"]
709
+    wheel3act = wheel3.actuators["Visibility"]
710
+    wheel4act = wheel4.actuators["Visibility"]
711
+            
712
+    if own['throw_deck'] == False:
713
+        own['throw_deck'] = True
714
+        deckact.visibility = False
715
+        trucksact.visibility = False
716
+        wheel1act.visibility = False
717
+        wheel2act.visibility = False
718
+        wheel3act.visibility = False
719
+        wheel4act.visibility = False
720
+        act = throw_deck_empty.actuators['throw_dec_act']
721
+        hard = strength * .08
722
+        if hard > 9:
723
+            hard = 9
724
+        if hard < 1:
725
+            hard = 1    
726
+        ud = ud * 4
727
+        own['bbut_timer'] = 0
728
+        if STANCE == True:
729
+            own['requestAction'] = 'fak_throw'
730
+            act.linearVelocity = [0.0, ud, hard]
731
+        if STANCE == False:
732
+            own['requestAction'] = 'fak_throw'
733
+            act.linearVelocity = [0.0, ud, -hard]  
734
+        cont.activate(act)
735
+    else:
736
+        own['throw_deck'] = False    
737
+        deckact.visibility = True
738
+        trucksact.visibility = True
739
+        wheel1act.visibility = True
740
+        wheel2act.visibility = True
741
+        wheel3act.visibility = True
742
+        wheel4act.visibility = True
743
+        throw_deck_empty['kill_deck'] = 1     
744
+    cont.activate(deck.actuators['Visibility'])
745
+    cont.activate(trucks.actuators['Visibility'])
746
+    cont.activate(wheel1.actuators['Visibility'])
747
+    cont.activate(wheel2.actuators['Visibility'])
748
+    cont.activate(wheel3.actuators['Visibility'])
749
+    cont.activate(wheel4.actuators['Visibility'])            
750
+def throwdeck_trigger():
751
+    lastb = own['lastb']
752
+    throw_deck_empty = scene.objects["throw_deck_empty"]
753
+    if bBut == True:
754
+        own['bbut_timer'] += 1
755
+        ud = (rUD * 10) +1
756
+    if bBut == False:
757
+        throw_deck_empty['kill_deck'] = 0
758
+    if bBut == False and own['lastb'] == True:        
759
+        strength = own['bbut_timer']
760
+        ud = (rUD * 10) +1
761
+        throwdeck(strength, ud)   
762
+        
763
+def focus_deck():
764
+    since_air = own['framenum'] - own['lF_air_frame']
765
+    if cb_td.positive and since_air < 10:
766
+        object = 'focus_deckA'
767
+        object2 = 'focus_deckB'            
768
+        other = throw_deck_empty
769
+        throw_deck = scene.objects["throw_deck"]
770
+        throw_deck.endObject()
771
+        scene.addObject(object, other, 0)          
772
+        scene.addObject(object2, other, 0)
773
+                
774
+    if own['throw_deck'] == True:
775
+        if dict['ldPad'] == False and dict['last_ldPad'] == True: 
776
+            object = 'focus_deckA'
777
+            object2 = 'focus_deckB'            
778
+            other = throw_deck_empty
779
+            scene.addObject(object, other, 0)          
780
+            scene.addObject(object2, other, 0)          
781
+              
782
+def fall():
783
+    if own['fall'] == True:
784
+        falldeck()        
785
+        if STANCE == 1:
786
+            own['requestAction'] = 'fak_air-walk_air'            
787
+            own.setLinearVelocity([3,2,0], True)
788
+        else:
789
+            own['requestAction'] = 'reg_air-walk_air'
790
+            own.setLinearVelocity([-3,-2,0], True)    
791
+        own['fall'] = False
792
+
793
+def sit():
794
+    #turn off sit
795
+    if lup == 1 or ldown == 1 or lUD > sens or lUD < -sens:
796
+        if own['sit'] == 1:
797
+            killact(300)
798
+            killact(299)
799
+        own['sit'] = 0
800
+
801
+    if aBut == False and lasta == True:
802
+        try:
803
+            if 'sit' in r_ground.hitObject:
804
+                #print("sit")
805
+                own['sit'] = 1
806
+                killact(3)
807
+                if STANCE == 0:
808
+                    own['requestAction'] = 'reg_sit'
809
+                elif STANCE == 1:
810
+                    own['requestAction'] = 'fak_sit'                                        
811
+        except:
812
+            pass    
813
+    if own['sit'] == 1:
814
+        try:
815
+            killact(3)
816
+            sit_vect = r_ground.hitObject.getAxisVect( [0, 1, 0])
817
+            if STANCE == 0:
818
+                own.alignAxisToVect(-sit_vect, 0, .2)
819
+                own['requestAction'] = 'reg_sit'                               
820
+                
821
+            elif STANCE == 1:
822
+                own['requestAction'] = 'fak_sit'
823
+                own.alignAxisToVect(sit_vect, 0, .2)                    
824
+        except:
825
+            pass    
826
+                      
827
+def switchcam():
828
+    if ltsBut == False and own['lastlts'] == True and rtsBut == False:
829
+        if own['camera'] == 1:
830
+            own['camera'] = 0
831
+        else:
832
+            own['camera'] = 1
833
+    if rtsBut == False and own['lastrts'] == True and ltsBut == False:
834
+        if own['camera'] == 2:
835
+            own['camera'] = 0
836
+        else:
837
+            own['camera'] = 2 
838
+#followcam 
839
+def move_followcam():
840
+    if own['camera'] == 2:
841
+        if own['lastbkBut'] == True and bkBut == False:
842
+            #print("activate move followcam") 
843
+            if own['move_followcam'] == False:
844
+                own['move_followcam'] = True
845
+            else:
846
+                own['move_followcam'] = False                       
847
+        if own['move_followcam'] == True:
848
+            camspeed1 = .015
849
+            camspeed2 = .055
850
+            camrot1 = .005
851
+            camrot2 = .02
852
+            #up
853
+            if lUD < -0.080:
854
+                followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
855
+                cont.activate(followcam.actuators["up"])
856
+                #print("fastup")
857
+            else:
858
+                cont.deactivate(followcam.actuators["up"])    
859
+#            #down    
860
+            if lUD > .080:
861
+                followcam.actuators["down"].dLoc = [ 0, 0, camspeed2]
862
+                cont.activate(followcam.actuators["down"])
863
+            else:
864
+                cont.deactivate(followcam.actuators["down"])                    
865
+#            #left
866
+            if lLR < -0.080:
867
+                followcam.actuators["left"].dLoc = [-camspeed2, 0, 0]                
868
+                cont.activate(followcam.actuators["left"])
869
+            else:
870
+                cont.deactivate(followcam.actuators["left"])                    
871
+#            #right
872
+            if lLR > 0.080:         
873
+                followcam.actuators["right"].dLoc = [camspeed2, 0, 0]                
874
+                cont.activate(followcam.actuators["right"])
875
+            else:
876
+                cont.deactivate(followcam.actuators["right"])  
877
+            #up
878
+            if rUD < -0.080:
879
+                followcam.actuators["rotup"].dLoc = [0, 0, camrot2]
880
+                cont.activate(followcam.actuators["rotup"])
881
+            else:
882
+                cont.deactivate(followcam.actuators["rotup"])    
883
+#            #down    
884
+            if rUD > .080:
885
+                followcam.actuators["rotdown"].dLoc = [0, 0, -camrot2]                
886
+                cont.activate(followcam.actuators["rotdown"])
887
+            else:
888
+                cont.deactivate(followcam.actuators["rotdown"])                    
889
+#            #left
890
+            if rLR < -0.080:
891
+                followcam.actuators["rotleft"].dRot = [0, 0, camrot2]                
892
+                cont.activate(followcam.actuators["rotleft"])
893
+            else:
894
+                cont.deactivate(followcam.actuators["rotleft"])                    
895
+#            #right
896
+            if rLR > 0.080:         
897
+                followcam.actuators["rotright"].dRot = [0, 0, -camrot2]
898
+                cont.activate(followcam.actuators["rotright"])
899
+            else:
900
+                cont.deactivate(followcam.actuators["rotright"]) 
901
+
902
+#*********************************************                
903
+                
904
+            if lUD > -0.080 and lUD < -0.030:
905
+                followcam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
906
+                cont.activate(followcam.actuators["up"])
907
+            else:
908
+                cont.deactivate(followcam.actuators["up"])    
909
+#            #down    
910
+            if lUD < .080 and lUD > .03:
911
+                followcam.actuators["down"].dLoc = [ 0, 0, camspeed1]                
912
+                cont.activate(followcam.actuators["down"])
913
+            else:
914
+                cont.deactivate(followcam.actuators["down"])                    
915
+#            #left
916
+            if lLR > -0.080 and lLR < -0.030:
917
+                followcam.actuators["left"].dLoc = [-camspeed1, 0, 0]                
918
+                cont.activate(followcam.actuators["left"])
919
+            else:
920
+                cont.deactivate(followcam.actuators["left"])                    
921
+#            #right
922
+            if lLR < .080 and lLR > .03:       
923
+                followcam.actuators["right"].dLoc = [camspeed1, 0, 0]
924
+                cont.activate(followcam.actuators["right"])
925
+            else:
926
+                cont.deactivate(followcam.actuators["right"])  
927
+            #up
928
+            if rUD > -0.080 and rUD < -0.030:
929
+                followcam.actuators["rotup"].dRot = [camrot1, 0, 0]                
930
+                cont.activate(followcam.actuators["rotup"])
931
+            else:
932
+                cont.deactivate(followcam.actuators["rotup"])    
933
+#            #down    
934
+            if rUD < .080 and rUD > .03:
935
+                followcam.actuators["rotdown"].dRot = [-camrot1, 0, 0]                
936
+                cont.activate(followcam.actuators["rotdown"])
937
+            else:
938
+                cont.deactivate(followcam.actuators["rotdown"])                    
939
+#            #left
940
+            if rLR > -0.080 and rLR < -0.030:
941
+                followcam.actuators["rotleft"].dRot = [0, 0, camrot1]
942
+                cont.activate(followcam.actuators["rotleft"])
943
+            else:
944
+                cont.deactivate(followcam.actuators["rotleft"])                    
945
+#            #right
946
+            if rLR < .080 and rLR > .03:         
947
+                followcam.actuators["rotright"].dRot = [0, 0, -camrot1]
948
+                cont.activate(followcam.actuators["rotright"])
949
+            else:
950
+                cont.deactivate(followcam.actuators["rotright"])                       
951
+def move_flycam():
952
+    if own['camera'] == 1:
953
+        if own['lastbkBut'] == True and bkBut == False: 
954
+            if own['move_freecam'] == False:
955
+                own['move_freecam'] = True
956
+            else:
957
+                own['move_freecam'] = False                       
958
+        if own['move_freecam'] == True:
959
+            camspeed1 = .015
960
+            camspeed2 = .055
961
+            camrot1 = .005
962
+            camrot2 = .02
963
+            #up
964
+            if lUD < -0.080:
965
+                freecam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
966
+                cont.activate(freecam.actuators["up"])
967
+            else:
968
+                cont.deactivate(freecam.actuators["up"])    
969
+#            #down    
970
+            if lUD > .080:
971
+                freecam.actuators["down"].dLoc = [ 0, 0, camspeed2]
972
+                cont.activate(freecam.actuators["down"])
973
+            else:
974
+                cont.deactivate(freecam.actuators["down"])                    
975
+#            #left
976
+            if lLR < -0.080:
977
+                freecam.actuators["left"].dLoc = [-camspeed2, 0, 0]                
978
+                cont.activate(freecam.actuators["left"])
979
+            else:
980
+                cont.deactivate(freecam.actuators["left"])                    
981
+#            #right
982
+            if lLR > 0.080:         
983
+                freecam.actuators["right"].dLoc = [camspeed2, 0, 0]                
984
+                cont.activate(freecam.actuators["right"])
985
+            else:
986
+                cont.deactivate(freecam.actuators["right"])  
987
+            #up
988
+            if rUD < -0.080:
989
+                freecam.actuators["rotup"].dRot = [camrot2, 0, 0]
990
+                cont.activate(freecam.actuators["rotup"])
991
+            else:
992
+                cont.deactivate(freecam.actuators["rotup"])    
993
+#            #down    
994
+            if rUD > .080:
995
+                freecam.actuators["rotdown"].dRot = [-camrot2, 0, 0]                
996
+                cont.activate(freecam.actuators["rotdown"])
997
+            else:
998
+                cont.deactivate(freecam.actuators["rotdown"])                    
999
+#            #left
1000
+            if rLR < -0.080:
1001
+                freecam.actuators["rotleft"].dRot = [0, 0, camrot2]                
1002
+                cont.activate(freecam.actuators["rotleft"])
1003
+            else:
1004
+                cont.deactivate(freecam.actuators["rotleft"])                    
1005
+#            #right
1006
+            if rLR > 0.080:         
1007
+                freecam.actuators["rotright"].dRot = [0, 0, -camrot2]
1008
+                cont.activate(freecam.actuators["rotright"])
1009
+            else:
1010
+                cont.deactivate(freecam.actuators["rotright"]) 
1011
+
1012
+#*********************************************                
1013
+                
1014
+            if lUD > -0.080 and lUD < -0.030:
1015
+                freecam.actuators["up"].dLoc = [ 0, 0, -camspeed1]
1016
+                cont.activate(freecam.actuators["up"])
1017
+                #print(lUD)
1018
+            else:
1019
+                cont.deactivate(freecam.actuators["up"])    
1020
+#            #down    
1021
+            if lUD < .080 and lUD > .03:
1022
+                freecam.actuators["down"].dLoc = [ 0, 0, camspeed1]                
1023
+                cont.activate(freecam.actuators["down"])
1024
+            else:
1025
+                cont.deactivate(freecam.actuators["down"])                    
1026
+#            #left
1027
+            if lLR > -0.080 and lLR < -0.030:
1028
+                freecam.actuators["left"].dLoc = [-camspeed1, 0, 0]                
1029
+                cont.activate(freecam.actuators["left"])
1030
+            else:
1031
+                cont.deactivate(freecam.actuators["left"])                    
1032
+#            #right
1033
+            if lLR < .080 and lLR > .03:       
1034
+                freecam.actuators["right"].dLoc = [camspeed1, 0, 0]
1035
+                cont.activate(freecam.actuators["right"])
1036
+            else:
1037
+                cont.deactivate(freecam.actuators["right"])  
1038
+            #up
1039
+            if rUD > -0.080 and rUD < -0.030:
1040
+                freecam.actuators["rotup"].dRot = [camrot1, 0, 0]                
1041
+                cont.activate(freecam.actuators["rotup"])
1042
+            else:
1043
+                cont.deactivate(freecam.actuators["rotup"])    
1044
+#            #down    
1045
+            if rUD < .080 and rUD > .03:
1046
+                freecam.actuators["rotdown"].dRot = [-camrot1, 0, 0]                
1047
+                cont.activate(freecam.actuators["rotdown"])
1048
+            else:
1049
+                cont.deactivate(freecam.actuators["rotdown"])                    
1050
+#            #left
1051
+            if rLR > -0.080 and rLR < -0.030:
1052
+                freecam.actuators["rotleft"].dRot = [0, 0, camrot1]
1053
+                cont.activate(freecam.actuators["rotleft"])
1054
+            else:
1055
+                cont.deactivate(freecam.actuators["rotleft"])                    
1056
+#            #right
1057
+            if rLR < .080 and rLR > .03:         
1058
+                freecam.actuators["rotright"].dRot = [0, 0, -camrot1]
1059
+                cont.activate(freecam.actuators["rotright"])
1060
+            else:
1061
+                cont.deactivate(freecam.actuators["rotright"])                     
1062
+if r_ground.triggered == False:
1063
+    cont.deactivate(own.actuators["walk_align"])
1064
+else:
1065
+    cont.activate(own.actuators["walk_align"])                    
1066
+
1067
+#walking on stairs
1068
+if r_ground.triggered:
1069
+    try:
1070
+        if 'stair' in r_ground.hitObject:
1071
+            own['stair_counter'] = 20
1072
+            
1073
+    except:
1074
+        pass        
1075
+    if own['stair_counter'] > 0:
1076
+        own.linearVelocity.z += .1
1077
+        own['stair_counter'] -= 1     
1078
+
1079
+if yBut == True:
1080
+    own['walk_idling'] = 0
1081
+    own["walk_idle_frame"] = 0
1082
+
1083
+
1084
+
1085
+if own['stair_counter'] > 5 and r_ground.triggered == False:
1086
+    own.applyForce([0,0,-200], True)                          
1087
+   
1088
+if deck.visible:
1089
+    own['deckvis'] = 1
1090
+else:
1091
+    own['deckvis'] = 0       
1092
+
1093
+if own['requestAction'] == 'empty' or own['requestAction'] == None:
1094
+    if STANCE == 0:
1095
+        own['requestAction'] = 'reg_idle1'
1096
+    if STANCE == 1:
1097
+        own['requestAction'] = 'fak_idle1'        
1098
+    
1099
+def onground():
1100
+    if r_ground.positive:
1101
+        own['lF_ground_frame'] = own['framenum']
1102
+        if 'grind' in r_ground.hitObject:
1103
+            if own['framenum'] - own['last_fall_frame'] < 90:
1104
+                own.applyForce([0,100,0], True)
1105
+                #print('moving away from rail')
1106
+                
1107
+        yvel = own.linearVelocity.y
1108
+        yvel = yvel *.1
1109
+        if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01 and own['stair_counter'] == 0:
1110
+            if STANCE == 0:
1111
+                own.applyRotation([0,0,-yvel], True) 
1112
+            else:
1113
+                own.applyRotation([0,0,yvel], True) 
1114
+        else:
1115
+            own.linearVelocity.y = 0                           
1116
+
1117
+    else:
1118
+        #print('in air')            
1119
+        if  own['framenum'] - own['lF_ground_frame'] > 10:
1120
+            if STANCE == 0:            
1121
+                own['requestAction'] = 'reg_walk_air'
1122
+            else:
1123
+                own['requestAction'] = 'fak_walk_air' 
1124
+    #if control bottom is touching ground object, turn ground on            
1125
+    if cb.positive:
1126
+        if own['framenum'] - own['last_fall_frame'] < 90:
1127
+            own['lF_ground_frame'] = own['framenum']
1128
+            
1129
+            
1130
+
1131
+def get_in_car():
1132
+    vehicleNear = cont.sensors["vehicleNear"]
1133
+    #print('vh', vehicleNear.positive)
1134
+    scene = bge.logic.getCurrentScene()
1135
+    cam = scene.active_camera
1136
+    #dict = bge.logic.globalDict 
1137
+    if vehicleNear.positive and 'car' in vehicleNear.hitObject:
1138
+        obj = vehicleNear.hitObject
1139
+        if yBut == True:
1140
+            obj['driving'] = True
1141
+            own['driving'] = True
1142
+            cube.suspendDynamics(True)
1143
+            cube.worldPosition = obj.worldPosition
1144
+            cube.worldOrientation = obj.worldOrientation
1145
+            rot = [ 0.0, 0.0, 1.570796327]
1146
+            cube.applyRotation(rot,False)            
1147
+            compound = False
1148
+
1149
+            # child is solid
1150
+            ghost = True
1151
+
1152
+            # set parent
1153
+            cube.setParent( obj, compound, ghost)            
1154
+            
1155
+            
1156
+
1157
+            #cam.target = obj
1158
+            #cam.state = 2
1159
+            cont.actuators['Camera'].object = obj
1160
+            cont.actuators['Camera'].height = 3
1161
+            cont.actuators['Camera'].min = 6
1162
+            cont.actuators['Camera'].max = 10
1163
+            own.state = 2
1164
+        #print('near car')
1165
+        
1166
+    if dict['last_driving'] == True:
1167
+        cont.actuators['Camera'].object = scene.objects['camCube']    
1168
+        cont.activate(cont.actuators['walk'])               
1169
+    if own['driving'] == False:  
1170
+        #cont.actuators['Camera'].object = scene.objects['camCube'] 
1171
+        #cont.activate(cont.actuators['walk']) 
1172
+        dict['last_driving'] = False
1173
+        
1174
+def get_on_bike(dict, own):
1175
+    #bikeCol = cont.sensors['bikeCol']
1176
+    vehicleNear = cont.sensors["vehicleNear"]
1177
+    #print('vh', vehicleNear.positive)
1178
+    scene = bge.logic.getCurrentScene()
1179
+    #cam = scene.active_camera
1180
+    #dict = bge.logic.globalDict 
1181
+    try:
1182
+        if vehicleNear.positive and 'bike' in vehicleNear.hitObject:          
1183
+            if yBut == True and dict['last_yBut'] == False and own['throw_deck'] == True:
1184
+                vehicleNear.hitObject.endObject()
1185
+                dict['bike'] = True 
1186
+                cont.activate(own.actuators['bike_state']) 
1187
+
1188
+                object = "player_bike"
1189
+                # instantly add bullet
1190
+                newbike = scene.addObject(object, own, 0)
1191
+                #bike.localScale = 4.6            
1192
+                newbike.setParent(cube, False, False)
1193
+                #rot = [ 0.0, 0.0, 1.570796327]
1194
+                #bike.applyRotation(rot,False) 
1195
+    except:
1196
+        pass            
1197
+                                              
1198
+if dict['driving_reset'] == True:
1199
+    scene.resume()
1200
+    cube.suspendDynamics(False)
1201
+    cont.actuators['Camera'].object = camobj2
1202
+    cont.activate(own.actuators['walk'])
1203
+    #dict['driving_reset'] = False
1204
+    #print('reseting driving')   
1205
+if own['walk_jump_timer'] != 0:
1206
+    own['walk_jump_timer'] = own['walk_jump_timer'] - 1    
1207
+wts = own['walk_targ_speed'] +1                 
1208
+if own['requestAction'] == 'reg_walkFast' and own.linearVelocity.x > (wts * -1):
1209
+    own['requestAction'] = 'reg_walk' 
1210
+if own['requestAction'] == 'fak_walkFast' and own.linearVelocity.x < wts:
1211
+    own['requestAction'] = 'fak_walk' 
1212
+if own['requestAction'] == 'reg_walkFast_nb' and own.linearVelocity.x > (wts * -1):
1213
+    own['requestAction'] = 'reg_walk_nb' 
1214
+if own['requestAction'] == 'fak_walkFast_nb' and own.linearVelocity.x < wts:
1215
+    own['requestAction'] = 'fak_walk_nb'                         
1216
+onboard() 
1217
+jump()
1218
+dropin()
1219
+throwdeck_trigger()
1220
+
1221
+nextframe()
1222
+checkidle()
1223
+getonboard(dict)
1224
+reset_pos()
1225
+switchcam()
1226
+move_flycam()
1227
+move_followcam()
1228
+fall()
1229
+idle_anim()
1230
+sit()
1231
+onground()
1232
+focus_deck()
1233
+get_in_car()
1234
+get_on_bike(dict, own)
1235
+
1236
+#printplaying() 
1237
+
1238
+own.alignAxisToVect([0.0,0.0,1.0], 2, .03)
1239
+own.actuators["sroll"].stopSound() 
1240
+wheel1 = scene.objects["rollen.000"]
1241
+wheel2 = scene.objects["rollen.001"]
1242
+wheel3 = scene.objects["rollen.002"]
1243
+wheel4 = scene.objects["rollen.003"]
1244
+wheel1.stopAction(2)
1245
+wheel2.stopAction(2)
1246
+wheel3.stopAction(2)
1247
+wheel4.stopAction(2)
1248
+own['lasty'] = yBut
1249
+own['lastb'] = bBut  
1250
+own['lasta'] = aBut
1251
+own['lastx'] = xBut   
1252
+own['lastlts'] = ltsBut
1253
+own['lastrts'] = rtsBut        
1254
+own['lastbkBut'] = bkBut
1255
+own['dropinCol'] = dropinCol
1256
+own['walk'] = 1
1257
+dict['walk'] = 1
1258
+    

Loading…
Cancel
Save