From: Stefano Rivera Date: Sat, 17 May 2014 22:46:50 +0000 (+0200) Subject: Autoscrolling credits X-Git-Tag: 0.1~10^2~11 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=d679de459e72fb86dfe71732f6512133782dbe9e;p=naja.git Autoscrolling credits --- diff --git a/naja/scenes/credits.py b/naja/scenes/credits.py index 9bb6d89..f967a72 100644 --- a/naja/scenes/credits.py +++ b/naja/scenes/credits.py @@ -3,6 +3,7 @@ Credits scene. """ +import pygame import pygame.locals as pgl from naja.constants import KEYS @@ -19,6 +20,7 @@ class CreditsScene(Scene): def __init__(self, state): super(CreditsScene, self).__init__(state) + self.autoscroll = 0 background = ImageBox( (0, 0), "screens/splash.png") @@ -26,7 +28,7 @@ class CreditsScene(Scene): 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', '', @@ -52,7 +54,21 @@ class CreditsScene(Scene): ]), 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: