From 1436eedb964abfa4d1c3b06813b832133812c7a5 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sun, 11 May 2014 17:06:23 +0200 Subject: [PATCH] Initial user events for Naja. --- naja/events.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 naja/events.py diff --git a/naja/events.py b/naja/events.py new file mode 100644 index 0000000..b2cdee1 --- /dev/null +++ b/naja/events.py @@ -0,0 +1,28 @@ +""" +Custom Pygame events. +""" + +import pygame.event as pge + + +class NajaEvent(pge.Event): + + TYPE = "UNKNOWN" + + @classmethod + def post(cls, **attributes): + event = pge.Event(pge.USEREVENT, naja_event_type=cls.TYPE, + **attributes) + pge.post(event) + + @classmethod + def matches(cls, ev): + return ev.type == pge.USEREVENT and ev.naja_event_type == cls.TYPE + + +class SceneChangeEvent(NajaEvent): + TYPE = "SCENE_CHANGE" + + @classmethod + def post(cls, scene): + super(SceneChangeEvent, cls).post(scene=scene) -- 2.34.1