That was too fast
[naja.git] / naja / scenes / credits.py
1 # coding: UTF-8
2 """
3 Credits scene.
4 """
5
6 import pygame
7 import pygame.locals as pgl
8
9 from naja.constants import KEYS, FPS
10 from naja.scenes.scene import Scene
11 from naja.widgets.text import TextWidget, TextBoxWidget
12 from naja.widgets.image_box import ImageBox
13 from naja.events import SceneChangeEvent
14
15
16 class CreditsScene(Scene):
17     """
18     List those responsible.
19     """
20
21     def __init__(self, state):
22         super(CreditsScene, self).__init__(state)
23         self.autoscroll = 0
24
25         background = ImageBox(
26             (0, 0), "screens/splash.png")
27         self.add(background)
28         self.add(TextWidget(
29             (400, 300), 'CREDITS', colour='white', centre=True))
30
31         self.credits = TextBoxWidget(
32             (400, 340), '\n'.join([
33                 'A game about robots and bits and other things',
34                 '',
35                 'by',
36                 '',
37                 u'Adrianna PiƄska, David Sharpe, Jeremy Thurgood, '
38                 u'Neil Muller, Simon Cross & Stefano Rivera',
39                 '',
40                 'Special thanks to:',
41                 '',
42                 'Desilu Crossman',
43                 'for snacks and tutorial inspiration',
44                 '',
45                 'Bearnard Hibbins, Graham Inggs,',
46                 'and William Stewart',
47                 'for playtesting and finding bugs',
48                 '',
49                 'Music by Rolemusic:',
50                 'http://rolemusic.sawsquarenoise.com/',
51                 '',
52                 'Out of credits. Insert coin.',
53                 '(Press ESC to return to the menu.)',
54             ]),
55             colour='white', padding=1,
56             bg_colour=(0, 0, 0, 0), centre=True,
57             box_width=780, view_port=(780, 250))
58         self.add(self.credits)
59
60     def render_scene(self, surface):
61         if self.autoscroll is not None:
62             self.autoscroll += 1
63         if self.autoscroll >= 1.5 * FPS:
64             fake_event = pygame.event.Event(pgl.KEYDOWN, key=pgl.K_DOWN)
65             self.credits.handle_event(fake_event)
66             self.autoscroll = 0
67
68     def handle_event(self, ev):
69         if ev.type == pgl.KEYDOWN:
70             self.autoscroll = None
71         return super(CreditsScene, self).handle_event(ev)
72
73     def handle_scene_event(self, ev):
74         if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT:
75             from naja.scenes.menu import MenuScene
76             SceneChangeEvent.post(MenuScene)
77             return