5 import pygame.event as pge
6 import pygame.locals as pgl
9 def finish_event(handled=True, events=(), skip_invalidate=False):
12 if not skip_invalidate:
13 InvalidateTheWorld.post()
17 class NajaEvent(object):
21 def post(cls, **attributes):
22 event = pge.Event(pgl.USEREVENT, naja_event_type=cls.TYPE,
28 return ev.type == pgl.USEREVENT and ev.naja_event_type == cls.TYPE
31 class SceneChangeEvent(NajaEvent):
35 def post(cls, scene_cls):
36 super(SceneChangeEvent, cls).post(scene_cls=scene_cls)
39 class QuitGameEvent(NajaEvent):
43 class InvalidateTheWorld(NajaEvent):
44 # This is used to signal to all the widgets that the world has changed
45 # and cached state may need to be recreated
49 class SelectEvent(NajaEvent):
53 class PlayerMoved(NajaEvent):
54 # This is used to signal to widgets that care that the player has moved.