2 import pygame.locals as pgl
4 from naja.constants import FPS
5 from naja.events import SceneChangeEvent, QuitGameEvent, LoadGameEvent
6 from naja.sound import sound
10 def __init__(self, surface, scene, state):
11 self._surface = surface
16 clock = pygame.time.Clock()
18 self._surface.fill((0, 0, 0))
19 for ev in pygame.event.get():
20 if ev.type == pgl.QUIT or QuitGameEvent.matches(ev):
23 elif SceneChangeEvent.matches(ev):
24 self.change_scene(ev.scene_cls)
25 elif LoadGameEvent.matches(ev):
26 self._state = ev.state
28 self._scene.handle_event(ev)
29 self._scene.render(self._surface)
33 def change_scene(self, scene_cls):
35 self._scene = scene_cls(self._state)
40 sound.play_sound('shutdown.ogg', foreground=True)