X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fscenes%2Fwin.py;h=5acff6e5f8abde20029a5ffe21018e038c0d4f0d;hb=a4cb14512c07e5677c295d56b475a9562936a5e6;hp=f4df54f9858b47b6427c4323c90d81d32f613481;hpb=6e39e48a5c9921df699a8540942f08dfbc12a14a;p=naja.git diff --git a/naja/scenes/win.py b/naja/scenes/win.py index f4df54f..5acff6e 100644 --- a/naja/scenes/win.py +++ b/naja/scenes/win.py @@ -5,9 +5,11 @@ Win scene. import pygame.locals as pgl 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((50, 50), 'You won!', colour=PALETTE.WHITE)) - self.add(TextWidget((50 + 64, 50), 'CHEATER!', colour=PALETTE.ORANGE)) + + 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( - (50, 100), '\n'.join([ + (50, y_offset), '\n\n'.join([ "You're great.", "You did well.", "You should be proud of yourself.", + "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