tweaked spacing on win and lose screens
[naja.git] / naja / scenes / win.py
1 """
2 Win scene.
3 """
4
5 import pygame.locals as pgl
6
7 from naja.constants import KEYS, PALETTE
8 from naja.events import SceneChangeEvent, LoadGameEvent
9 from naja.sound import sound
10 from naja.scenes.scene import Scene
11 from naja.widgets.image_box import ImageBox
12 from naja.widgets.text import TextWidget, TextBoxWidget
13
14
15 class WinScene(Scene):
16     """
17     Congratulations.
18     """
19
20     def __init__(self, state):
21         super(WinScene, self).__init__(state)
22
23         background = ImageBox(
24             (0, 0), "screens/you_won.png")
25         self.add(background)
26
27         y_offset = 250
28
29         if self.state.gameboard.has_cheated:
30             self.add(TextWidget(
31                 (50, y_offset), 'But you\'re a CHEATER!', colour=PALETTE.ORANGE))
32             y_offset += 50
33
34         self.add(TextBoxWidget(
35             (50, y_offset), '\n\n'.join([
36                 "You're great.",
37                 "You did well.",
38                 "You should be proud of yourself.",
39                 "Press ESC to return to the menu",
40             ]),
41             colour=PALETTE.WHITE, padding=1, border=1,
42             bg_colour=PALETTE.BLACK, border_colour=PALETTE.BLACK,
43             box_width=300))
44         sound.play_music('A_ninja.ogg', 0.25)
45
46     def handle_scene_event(self, ev):
47         from naja.scenes.menu import MenuScene
48         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
49             sound.stop()
50             # drop current state
51             LoadGameEvent.post(None)
52             SceneChangeEvent.post(MenuScene)
53             return