self.quit_game()
return
elif SceneChangeEvent.matches(ev):
- self.change_scene(ev.scene)
+ self.change_scene(ev.scene_cls)
else:
self._scene.handle_event(ev)
self._scene.render(self._surface)
pygame.display.flip()
clock.tick(FPS)
- def change_scene(self, scene):
+ def change_scene(self, scene_cls):
self._scene.exit()
- self._scene = scene
+ self._scene = scene_cls(self._state)
self._scene.enter()
def quit_game(self):
TYPE = "SCENE_CHANGE"
@classmethod
- def post(cls, scene):
- super(SceneChangeEvent, cls).post(scene=scene)
+ def post(cls, scene_cls):
+ super(SceneChangeEvent, cls).post(scene_cls=scene_cls)
class QuitGameEvent(NajaEvent):
E.g. Splash screen, game board, credits, win, lose.
"""
- def __init__(self):
+ def __init__(self, state):
+ self.state = state
self.widgets = []
def enter(self):