Browse Source

moving scripts folder

shuvit 2 years ago
parent
commit
6a96bfdc1a

+ 129
- 0
scripts/DList.py View File

@@ -0,0 +1,129 @@
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

@@ -0,0 +1,596 @@
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

@@ -0,0 +1,172 @@
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

@@ -0,0 +1,2 @@
1
+# shuvit
2
+Open source skateboarding game made with UPBGE / Blender.

+ 716
- 0
scripts/Record.py View File

@@ -0,0 +1,716 @@
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

@@ -0,0 +1,96 @@
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

@@ -0,0 +1,673 @@
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

@@ -0,0 +1,153 @@
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

@@ -0,0 +1,12 @@
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

@@ -0,0 +1,576 @@
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"])