Mercurial > fife-parpg
diff demos/shooter/scripts/world.py @ 469:5994e61cdebd
Added a widget to be displayed after the player completes the game.
Renamed the showHighScoreDialog function to saveScore.
Player can no longer collide with the boss causing the boss to be destroyed. The player now gets destroyed and the boss takes no damage.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 14 Apr 2010 17:42:24 +0000 |
parents | ebbb420a90b9 |
children | 7a79dc2a0592 |
line wrap: on
line diff
--- a/demos/shooter/scripts/world.py Wed Apr 14 16:35:07 2010 +0000 +++ b/demos/shooter/scripts/world.py Wed Apr 14 17:42:24 2010 +0000 @@ -77,9 +77,12 @@ self._highscores = HighScores(self) self._highscores.hide() + self._winner = WinnerDisplay() + self._winner.hide() + self._genericrenderer = None - self._sceneended = False + self._gamecomplete = False def showMainMenu(self): if self.scene: @@ -101,7 +104,6 @@ self._applictaion.requestQuit() def reset(self): - #TODO: ensure these get destroyed correctly if self.map: self.model.deleteMap(self.map) self.map = None @@ -112,12 +114,15 @@ self.scene.destroyScene() self.scene = None - self._sceneended = False + self._gamecomplete = False def loadLevel(self, filename): """ Load a xml map and setup cameras. """ + + self.resetKeys() + self.filename = filename self.reset() self.map = loadMapFile(self.filename, self.engine) @@ -129,6 +134,7 @@ self._hudwindow.show() self._gameover.hide() + self._winner.hide() self._starttime = self.timemanager.getTime() @@ -195,21 +201,20 @@ def gameOver(self): self._gameover.show() + self._hudwindow.hide() - if self._highscores.isHighScore(self.scene.player.score): - dlg = pychan.loadXML('gui/highscoredialog.xml') - dlg.execute({ 'okay' : "Yay!" }) - name = dlg.findChild(name='name').text - - self._highscores.addHighScore(HighScore(name, self.scene.player.score)) - self._highscores.show() + self.saveScore() def endLevel(self): self._paused = True - self._sceneended = True + + #only one level so the game is over once you complete it. + self._gamecomplete = True + self._winner.show() + self._hudwindow.hide() - def showHighScoreDialog(self): - self._sceneended = False + def saveScore(self): + self._gamecomplete = False if self._highscores.isHighScore(self.scene.player.score): score = self.scene.player.score @@ -243,6 +248,14 @@ self.scene.attachCamera(self.cameras['main']) + def resetKeys(self): + self.keystate['UP'] = False + self.keystate['DOWN'] = False + self.keystate['LEFT'] = False + self.keystate['RIGHT'] = False + self.keystate['SPACE'] = False + self.keystate['CTRL'] = False + def keyPressed(self, evt): keyval = evt.getKey().getValue() @@ -300,8 +313,8 @@ Called every frame. """ - if self._sceneended: - self.showHighScoreDialog() + if self._gamecomplete: + self.saveScore() self.reset() if self._genericrenderer: