+# coding: UTF-8
"""
Credits scene.
"""
+import pygame
import pygame.locals as pgl
-from naja.constants import KEYS
+from naja.constants import KEYS, FPS
from naja.scenes.scene import Scene
+from naja.utils import Flashlight
from naja.widgets.text import TextWidget, TextBoxWidget
+from naja.widgets.image_box import ImageBox
from naja.events import SceneChangeEvent
def __init__(self, state):
super(CreditsScene, self).__init__(state)
+ self.flashlight = Flashlight(int(1.5 * FPS))
+
+ background = ImageBox(
+ (0, 0), "screens/splash.png")
+ self.add(background)
self.add(TextWidget(
- (280, 30), 'Credits', fontsize=32, colour='white'))
- self.add(TextWidget(
- (20, 80), 'A game about robots and bits and other things',
- fontsize=32, colour='white'))
- self.add(TextWidget(
- (300, 120), 'by', fontsize=32, colour='white'))
- self.add(TextBoxWidget(
- (20, 160), 'Adrianna Pinska, David Sharpe, Jeremy Thurgood, '
- 'Neil Muller, Simon Cross & Stefano Rivera',
- fontsize=32, colour='white', padding=1, border=1,
- bg_colour='black', border_colour='black',
- box_width=320))
- self.add(TextBoxWidget(
- (30, 280),
- 'Music by Rolemusic: http://rolemusic.sawsquarenoise.com/',
- fontsize=32, colour='white', padding=1, border=1,
- bg_colour='black', border_colour='black',
- box_width=320))
+ (400, 300), 'CREDITS', colour='white', centre=True))
+
+ self.credits = TextBoxWidget(
+ (400, 340), '\n'.join([
+ 'A game about robots and bits and other things',
+ '',
+ 'by',
+ '',
+ u'Adrianna PiĆska, David Sharpe, Jeremy Thurgood, '
+ u'Neil Muller, Simon Cross & Stefano Rivera',
+ '',
+ 'Special thanks to:',
+ '',
+ 'Desilu Crossman',
+ 'for snacks and tutorial inspiration',
+ '',
+ 'Bearnard Hibbins, Graham Inggs,',
+ 'and William Stewart',
+ 'for playtesting and finding bugs',
+ '',
+ 'Music by Rolemusic:',
+ 'http://rolemusic.sawsquarenoise.com/',
+ '',
+ 'Out of credits. Insert coin.',
+ '(Press ESC to return to the menu.)',
+ ]),
+ colour='white', padding=1,
+ bg_colour=(0, 0, 0, 0), centre=True,
+ box_width=780, view_port=(780, 250))
+ self.add(self.credits)
+
+ def render_scene(self, surface):
+ if self.flashlight is not None:
+ if self.flashlight.tick():
+ fake_event = pygame.event.Event(pgl.KEYDOWN, key=pgl.K_DOWN)
+ self.credits.handle_event(fake_event)
+
+ def handle_event(self, ev):
+ if ev.type == pgl.KEYDOWN:
+ self.flashlight = None
+ return super(CreditsScene, self).handle_event(ev)
def handle_scene_event(self, ev):
if ev.type == pgl.KEYDOWN and ev.key in KEYS.QUIT: