Win and lose screens and conditions.
[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
8 from naja.scenes.scene import Scene
9 from naja.widgets.text import TextWidget, TextBoxWidget
10 from naja.events import QuitGameEvent
11
12
13 class WinScene(Scene):
14     """
15     Congratulations.
16     """
17
18     def __init__(self, state):
19         super(WinScene, self).__init__(state)
20         self.add(TextWidget(
21             (480, 160), 'You won!', fontsize=32, colour='white'))
22         self.add(TextBoxWidget(
23             (120, 30), '\n'.join([
24                 "You're great.",
25                 "You did well.",
26                 "You should be proud of yourself.",
27             ]), fontsize=32,
28             colour='white', padding=1, border=1,
29             bg_colour='black', border_colour='black',
30             box_width=100))
31
32     def handle_scene_event(self, ev):
33         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
34             QuitGameEvent.post()
35             return