aboutsummaryrefslogtreecommitdiff
path: root/game/QuitScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/QuitScript.cpp')
-rw-r--r--game/QuitScript.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/game/QuitScript.cpp b/game/QuitScript.cpp
new file mode 100644
index 0000000..e48863f
--- /dev/null
+++ b/game/QuitScript.cpp
@@ -0,0 +1,23 @@
+
+
+#include "QuitScript.h"
+#include "api/Event.h"
+#include "api/KeyCodes.h"
+
+
+using namespace crepe;
+
+bool QuitScript::on_event(const KeyPressEvent & ev){
+ if (Keycode::ESCAPE == ev.key) {
+ trigger_event<ShutDownEvent>(ShutDownEvent{});
+ }
+ return false;
+}
+
+
+
+void QuitScript::init(){
+ subscribe<KeyPressEvent>([this](const KeyPressEvent & ev) -> bool {
+ return this->on_event(ev);
+ });
+}