changeset 157:e3572b907028

Add splash images to game over screen.
author Simon Cross <hodgestar@gmail.com>
date Thu, 03 Sep 2009 21:45:57 +0000
parents 210fc1ea0516
children baf857805867
files gamelib/gameover.py
diffstat 1 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gameover.py	Thu Sep 03 21:23:34 2009 +0000
+++ b/gamelib/gameover.py	Thu Sep 03 21:45:57 2009 +0000
@@ -10,22 +10,26 @@
 def create_game_over(gameboard):
     """Create a game over screen"""
     game_over = GameOver(gameboard)
-
-    c = GameOverContainer(align=0, valign=0)
-    c.add(game_over, 0, 0)
-
-    return c
+    return GameOverContainer(game_over, align=0, valign=0)
 
 class GameOverContainer(gui.Container):
+    def __init__(self, game_over, *args, **kwargs):
+        gui.Container.__init__(self, *args, **kwargs)
+        self.add(game_over, 0, 0)
+        if game_over.survived:
+            self.splash = imagecache.load_image("images/gameover_win.png")
+        else:
+            self.splash = imagecache.load_image("images/gameover_lose.png")
+
     def paint(self, s):
         pygame.display.set_caption('Game Over')
-        #splash = imagecache.load_image("images/splash.png")
-        #pygame.display.get_surface().blit(splash, (0, 0))
+        pygame.display.get_surface().blit(self.splash, (0, 0))
         gui.Container.paint(self, s)
 
 class GameOver(gui.Table):
     def __init__(self, gameboard, **params):
         gui.Table.__init__(self, **params)
+        self.tr()
 
         def return_pressed():
             pygame.event.post(engine.GO_MAIN_MENU)
@@ -34,9 +38,11 @@
             pygame.event.post(engine.QUIT)
 
         if len(gameboard.chickens) > 0:
+            self.survived = True
             self.td(gui.Label("You Survived", color=constants.FG_COLOR),
                     colspan=3)
         else:
+            self.survived = False
             self.td(gui.Label("You Lost", color=constants.FG_COLOR),
                     colspan=3)
 
@@ -53,6 +59,9 @@
             constants.SELL_PRICE_EGG * gameboard.eggs),
             color=constants.FG_COLOR), colspan=3)
 
+        self.tr()
+        self.td(gui.Spacer(0, 50), colspan=3)
+
         return_button = gui.Button("Return to Main Menu")
         return_button.connect(gui.CLICK, return_pressed)