comparison demos/shooter/scripts/world.py @ 467:4d0aa75a82f1

Added damage so some enemies take more than one hit to destroy. Added the boss at the end of the level. For some reason the high score dialog box that appears after the level is completed causes a crash. Still looking into this one.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 14 Apr 2010 16:22:36 +0000
parents 4e58dab2fcdc
children ebbb420a90b9
comparison
equal deleted inserted replaced
466:716d44ba42df 467:4d0aa75a82f1
77 self._highscores = HighScores(self) 77 self._highscores = HighScores(self)
78 self._highscores.hide() 78 self._highscores.hide()
79 79
80 self._genericrenderer = None 80 self._genericrenderer = None
81 81
82 self._sceneended = False
83
82 def showMainMenu(self): 84 def showMainMenu(self):
83 if self.scene: 85 if self.scene:
84 self._paused = True 86 self._paused = True
85 cont = True 87 cont = True
86 else: 88 else:
103 if self.map: 105 if self.map:
104 self.model.deleteMap(self.map) 106 self.model.deleteMap(self.map)
105 self.map = None 107 self.map = None
106 108
107 self.cameras = {} 109 self.cameras = {}
108 self.scene = None 110
111 if self.scene:
112 self.scene.destroyScene()
113 self.scene = None
114
115 self._sceneended = False
109 116
110 def loadLevel(self, filename): 117 def loadLevel(self, filename):
111 """ 118 """
112 Load a xml map and setup cameras. 119 Load a xml map and setup cameras.
113 """ 120 """
191 198
192 if self._highscores.isHighScore(self.scene.player.score): 199 if self._highscores.isHighScore(self.scene.player.score):
193 dlg = pychan.loadXML('gui/highscoredialog.xml') 200 dlg = pychan.loadXML('gui/highscoredialog.xml')
194 dlg.execute({ 'okay' : "Yay!" }) 201 dlg.execute({ 'okay' : "Yay!" })
195 name = dlg.findChild(name='name').text 202 name = dlg.findChild(name='name').text
203
196 self._highscores.addHighScore(HighScore(name, self.scene.player.score)) 204 self._highscores.addHighScore(HighScore(name, self.scene.player.score))
197 self._highscores.show() 205 self._highscores.show()
198 206
207 def endLevel(self):
208 #there is only one level so do the high score display
209 self._paused = True
210
211 if self._highscores.isHighScore(self.scene.player.score):
212 score = self.scene.player.score
213 #self.reset()
214
215 dlg = pychan.loadXML('gui/highscoredialog.xml')
216 dlg.execute({ 'okay' : "Yay!" })
217 name = dlg.findChild(name='name').text
218
219 #self._highscores.addHighScore(HighScore(name, score))
220 #self._highscores.show()
221
222 self._sceneended = True
223
224
199 225
200 def newGame(self): 226 def newGame(self):
201 self.loadLevel("maps/shooter_map1.xml") 227 self.loadLevel("maps/shooter_map1.xml")
202 self._mainmenu.hide() 228 self._mainmenu.hide()
203 self._paused = False 229 self._paused = False
273 def pump(self): 299 def pump(self):
274 """ 300 """
275 Called every frame. 301 Called every frame.
276 """ 302 """
277 303
304 if self._sceneended:
305 self.reset()
306 self.showMainMenu()
307
278 if self._genericrenderer: 308 if self._genericrenderer:
279 self._genericrenderer.removeAll("quads") 309 self._genericrenderer.removeAll("quads")
280 310
281 311
282 if not self.scene: 312 if not self.scene:
318 348
319 else: 349 else:
320 if not self.scene.paused: 350 if not self.scene.paused:
321 self.scene.pause(self.timemanager.getTime() - self._starttime) 351 self.scene.pause(self.timemanager.getTime() - self._starttime)
322 352
353
323 self.pump_ctr += 1 354 self.pump_ctr += 1