summaryrefslogtreecommitdiff
path: root/riseoftodmoldren/base.py
diff options
context:
space:
mode:
authorRoman Gräf <romangraef@loves.dicksinhisan.us>2020-08-19 23:51:13 +0200
committerRoman Gräf <romangraef@loves.dicksinhisan.us>2020-08-19 23:51:13 +0200
commit55105b36d54c8e77251ad424fcdf8826a9d3df8d (patch)
tree4711f3b0cde0b80d2d7ce5e90ddb8e58712444ad /riseoftodmoldren/base.py
parentcc0fc4424363fcc2ccdbc8b0854b20147a2dd335 (diff)
downloadRise-of-Todmoldren-master.tar.gz
Rise-of-Todmoldren-master.tar.bz2
Rise-of-Todmoldren-master.zip
I got demotivated, im gonna leave it here.HEADmaster
Diffstat (limited to 'riseoftodmoldren/base.py')
-rw-r--r--riseoftodmoldren/base.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/riseoftodmoldren/base.py b/riseoftodmoldren/base.py
index c3549e5..c67fd04 100644
--- a/riseoftodmoldren/base.py
+++ b/riseoftodmoldren/base.py
@@ -64,6 +64,9 @@ class State:
def on_start(self, app: 'StateApp'):
pass
+ def on_keydown(self, app: 'StateApp', key):
+ pass
+
class StateApp(BaseApp):
@@ -73,6 +76,15 @@ class StateApp(BaseApp):
def on_event(self, event):
self.states[-1].on_event(self, event)
+ if event.type == pygame.QUIT:
+ self.should_close = True
+ if event.type == pygame.KEYDOWN:
+ self.on_keydown(event.key)
+
+ def on_keydown(self, key):
+ if key == pygame.K_ESCAPE:
+ self.should_close = True
+ self.states[-1].on_keydown(self, key)
def on_start(self):
self.states[-1].on_start(self)