Browse Source

Necessary changes for MusicPlayer

Some dictionary values were not initialized during startup and instead used try/catch blocks to instantiate them. I replaced the try's in the proper files and without these changes the MusicPlayer probably won't work.
Farmerjoe12 5 years ago
parent
commit
865f92966d
2 changed files with 294 additions and 297 deletions
  1. 154
    150
      Startup.py
  2. 140
    147
      npause.py

+ 154
- 150
Startup.py View File

@@ -1,150 +1,154 @@
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
-
150
-main()
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
+    
150
+    dict['npause'] = False
151
+    dict['last_npause'] = False
152
+    dict['playback'] = False
153
+
154
+main()

+ 140
- 147
npause.py View File

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

Loading…
Cancel
Save