Credits scene.
"""
+import pygame
import pygame.locals as pgl
from naja.constants import KEYS
def __init__(self, state):
super(CreditsScene, self).__init__(state)
+ self.autoscroll = 0
background = ImageBox(
(0, 0), "screens/splash.png")
self.add(TextWidget(
(400, 300), 'CREDITS', colour='white', centre=True))
- self.add(TextBoxWidget(
+ self.credits = TextBoxWidget(
(400, 340), '\n'.join([
'A game about robots and bits and other things',
'',
]),
colour='white', padding=1,
bg_colour=(0, 0, 0, 0), centre=True,
- box_width=780, view_port=(780, 250)))
+ box_width=780, view_port=(780, 250))
+ self.add(self.credits)
+
+ def render_scene(self, surface):
+ if self.autoscroll is not None:
+ self.autoscroll += 1
+ if self.autoscroll >= 24:
+ fake_event = pygame.event.Event(pgl.KEYDOWN, key=pgl.K_DOWN)
+ self.credits.handle_event(fake_event)
+ self.autoscroll = 0
+
+ def handle_event(self, ev):
+ if ev.type == pgl.KEYDOWN:
+ self.autoscroll = 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: