Initial user events for Naja.
[naja.git] / naja / events.py
1 """
2 Custom Pygame events.
3 """
4
5 import pygame.event as pge
6
7
8 class NajaEvent(pge.Event):
9
10     TYPE = "UNKNOWN"
11
12     @classmethod
13     def post(cls, **attributes):
14         event = pge.Event(pge.USEREVENT, naja_event_type=cls.TYPE,
15                           **attributes)
16         pge.post(event)
17
18     @classmethod
19     def matches(cls, ev):
20         return ev.type == pge.USEREVENT and ev.naja_event_type == cls.TYPE
21
22
23 class SceneChangeEvent(NajaEvent):
24     TYPE = "SCENE_CHANGE"
25
26     @classmethod
27     def post(cls, scene):
28         super(SceneChangeEvent, cls).post(scene=scene)