2 import pygame.locals as pgl
4 from naja.constants import FPS
5 from naja.events import SceneChangeEvent, QuitGameEvent
9 def __init__(self, surface, scene, state):
10 self._surface = surface
15 clock = pygame.time.Clock()
17 self._surface.fill((0, 0, 0))
18 for ev in pygame.event.get():
19 if ev.type == pgl.QUIT or QuitGameEvent.matches(ev):
22 elif SceneChangeEvent.matches(ev):
23 self.change_scene(ev.scene_cls)
25 self._scene.handle_event(ev)
26 self._scene.render(self._surface)
30 def change_scene(self, scene_cls):
32 self._scene = scene_cls(self._state)