From c31d52d5fcb73427dcc99e1294d7a70acdd82190 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 18 May 2014 00:59:48 +0200 Subject: [PATCH] Use Flashlight to drive the hack --- naja/scenes/credits.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/naja/scenes/credits.py b/naja/scenes/credits.py index b3fd4bd..8a6cfc2 100644 --- a/naja/scenes/credits.py +++ b/naja/scenes/credits.py @@ -8,6 +8,7 @@ import pygame.locals as pgl 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 @@ -20,7 +21,7 @@ class CreditsScene(Scene): def __init__(self, state): super(CreditsScene, self).__init__(state) - self.autoscroll = 0 + self.flashlight = Flashlight(int(1.5 * FPS)) background = ImageBox( (0, 0), "screens/splash.png") @@ -58,16 +59,14 @@ class CreditsScene(Scene): self.add(self.credits) def render_scene(self, surface): - if self.autoscroll is not None: - self.autoscroll += 1 - if self.autoscroll >= 1.5 * FPS: - fake_event = pygame.event.Event(pgl.KEYDOWN, key=pgl.K_DOWN) - self.credits.handle_event(fake_event) - self.autoscroll = 0 + 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.autoscroll = None + self.flashlight = None return super(CreditsScene, self).handle_event(ev) def handle_scene_event(self, ev): -- 2.34.1