tweaked spacing on win and lose screens
[naja.git] / naja / scenes / win.py
index 65765d769014ca38abadb5fa42c4db605ec1cc0c..5acff6e5f8abde20029a5ffe21018e038c0d4f0d 100644 (file)
@@ -4,10 +4,12 @@ Win scene.
 
 import pygame.locals as pgl
 
-from naja.constants import KEYS
+from naja.constants import KEYS, PALETTE
+from naja.events import SceneChangeEvent, LoadGameEvent
+from naja.sound import sound
 from naja.scenes.scene import Scene
+from naja.widgets.image_box import ImageBox
 from naja.widgets.text import TextWidget, TextBoxWidget
-from naja.events import QuitGameEvent
 
 
 class WinScene(Scene):
@@ -17,19 +19,35 @@ class WinScene(Scene):
 
     def __init__(self, state):
         super(WinScene, self).__init__(state)
-        self.add(TextWidget(
-            (480, 160), 'You won!', fontsize=32, colour='white'))
+
+        background = ImageBox(
+            (0, 0), "screens/you_won.png")
+        self.add(background)
+
+        y_offset = 250
+
+        if self.state.gameboard.has_cheated:
+            self.add(TextWidget(
+                (50, y_offset), 'But you\'re a CHEATER!', colour=PALETTE.ORANGE))
+            y_offset += 50
+
         self.add(TextBoxWidget(
-            (120, 30), '\n'.join([
+            (50, y_offset), '\n\n'.join([
                 "You're great.",
                 "You did well.",
                 "You should be proud of yourself.",
-            ]), fontsize=32,
-            colour='white', padding=1, border=1,
-            bg_colour='black', border_colour='black',
-            box_width=100))
+                "Press ESC to return to the menu",
+            ]),
+            colour=PALETTE.WHITE, padding=1, border=1,
+            bg_colour=PALETTE.BLACK, border_colour=PALETTE.BLACK,
+            box_width=300))
+        sound.play_music('A_ninja.ogg', 0.25)
 
     def handle_scene_event(self, ev):
+        from naja.scenes.menu import MenuScene
         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
-            QuitGameEvent.post()
+            sound.stop()
+            # drop current state
+            LoadGameEvent.post(None)
+            SceneChangeEvent.post(MenuScene)
             return