diff options
Diffstat (limited to 'game/QuitScript.cpp')
-rw-r--r-- | game/QuitScript.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/game/QuitScript.cpp b/game/QuitScript.cpp new file mode 100644 index 0000000..0c9f55a --- /dev/null +++ b/game/QuitScript.cpp @@ -0,0 +1,21 @@ + + +#include "QuitScript.h" + +#include <crepe/api/Event.h> +#include <crepe/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); + }); +} |