win & lose return to main menu
[naja.git] / naja / scenes / lose.py
1 """
2 Lose scene.
3 """
4
5 import pygame.locals as pgl
6
7 from naja.constants import KEYS, PALETTE
8 from naja.scenes.scene import Scene
9 from naja.widgets.image_box import ImageBox
10 from naja.widgets.text import TextWidget, TextBoxWidget
11 from naja.events import SceneChangeEvent
12
13
14 class LoseScene(Scene):
15     """
16     Commiserations.
17     """
18
19     def __init__(self, state):
20         super(LoseScene, self).__init__(state)
21
22         background = ImageBox(
23             (0, 0), "screens/you_lost.png")
24         self.add(background)
25
26
27         #self.add(TextWidget(
28         #    (50, 50), 'You lost!', colour=PALETTE.WHITE))
29
30         if self.state.gameboard.has_cheated:
31             self.add(TextWidget(
32                 (50, 250), 'Even with cheats on.', colour=PALETTE.ORANGE))
33
34         self.add(TextBoxWidget(
35             (50, 300), '\n\n'.join([
36                 "Something went terribly wrong.",
37                 "You should re-evaluate your life choices.",
38                 "",
39                 "Press ESC to return to the menu",
40             ]), fontsize=32,
41             colour='white', padding=1, border=1,
42             bg_colour='black', border_colour='black',
43             box_width=300))
44
45     def handle_scene_event(self, ev):
46         from naja.scenes.menu import MenuScene
47         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
48             SceneChangeEvent.post(MenuScene)
49             return