projects
/
naja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add widgets and skeleton for game scene.
[naja.git]
/
naja
/
events.py
diff --git
a/naja/events.py
b/naja/events.py
index b2cdee1e5a748e614c604af3b5913ff167db1874..01df79c162a34b5c652374847296f1623b082fa6 100644
(file)
--- a/
naja/events.py
+++ b/
naja/events.py
@@
-3,21
+3,22
@@
Custom Pygame events.
"""
import pygame.event as pge
"""
import pygame.event as pge
+import pygame.locals as pgl
-class NajaEvent(
pge.Even
t):
+class NajaEvent(
objec
t):
TYPE = "UNKNOWN"
@classmethod
def post(cls, **attributes):
TYPE = "UNKNOWN"
@classmethod
def post(cls, **attributes):
- event = pge.Event(pg
e
.USEREVENT, naja_event_type=cls.TYPE,
+ event = pge.Event(pg
l
.USEREVENT, naja_event_type=cls.TYPE,
**attributes)
pge.post(event)
@classmethod
def matches(cls, ev):
**attributes)
pge.post(event)
@classmethod
def matches(cls, ev):
- return ev.type == pg
e
.USEREVENT and ev.naja_event_type == cls.TYPE
+ return ev.type == pg
l
.USEREVENT and ev.naja_event_type == cls.TYPE
class SceneChangeEvent(NajaEvent):
class SceneChangeEvent(NajaEvent):
@@
-26,3
+27,11
@@
class SceneChangeEvent(NajaEvent):
@classmethod
def post(cls, scene):
super(SceneChangeEvent, cls).post(scene=scene)
@classmethod
def post(cls, scene):
super(SceneChangeEvent, cls).post(scene=scene)
+
+
+class QuitGameEvent(NajaEvent):
+ TYPE = "QUIT_GAME"
+
+ @classmethod
+ def post(cls):
+ super(QuitGameEvent, cls).post()