# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1271266944 0 # Node ID 5994e61cdebd19d2a467d06789972c9516fa6426 # Parent ebbb420a90b962650aa72073d4aaf16a35ef40f5 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. diff -r ebbb420a90b9 -r 5994e61cdebd demos/shooter/gui/winner.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/shooter/gui/winner.xml Wed Apr 14 17:42:24 2010 +0000 @@ -0,0 +1,7 @@ + + + + + + diff -r ebbb420a90b9 -r 5994e61cdebd demos/shooter/scripts/gui/guis.py --- a/demos/shooter/scripts/gui/guis.py Wed Apr 14 16:35:07 2010 +0000 +++ b/demos/shooter/scripts/gui/guis.py Wed Apr 14 17:42:24 2010 +0000 @@ -76,6 +76,10 @@ def hide(self): self._widget.hide() + def isVisible(self): + return self._widget.isVisible() + + class HeadsUpDisplay(object): def __init__(self, world): self._world = world @@ -119,6 +123,16 @@ def hide(self): self._widget.hide() +class WinnerDisplay(object): + def __init__(self): + self._widget = pychan.loadXML('gui/winner.xml') + + def show(self): + self._widget.show() + + def hide(self): + self._widget.hide() + class HighScore(object): def __init__(self, name, score): self._name = name @@ -342,4 +356,7 @@ def hide(self): self.saveHighScores() - self._widget.hide() \ No newline at end of file + self._widget.hide() + + def isVisible(self): + return self._widget.isVisible() \ No newline at end of file diff -r ebbb420a90b9 -r 5994e61cdebd demos/shooter/scripts/scene.py --- a/demos/shooter/scripts/scene.py Wed Apr 14 16:35:07 2010 +0000 +++ b/demos/shooter/scripts/scene.py Wed Apr 14 17:42:24 2010 +0000 @@ -283,7 +283,8 @@ #re-initialize scene if not self._player.invulnerable: self.playerHit() - obj.destroy() + if obj != self._boss: + obj.destroy() # self._world.renderBoundingBox(obj) diff -r ebbb420a90b9 -r 5994e61cdebd demos/shooter/scripts/world.py --- 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: