diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-12-19 11:21:37 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-12-19 11:21:37 +0100 |
commit | ea970a901d169824a99a336eacd06ebc032e5f66 (patch) | |
tree | 6f939f3a3a9593c0c4cceacd202665f83b7073f6 /src/example/MoveCameraManualyScript.cpp | |
parent | edd5fd83f4a5337ba06955bd59a136f7eb699234 (diff) |
Moved scripts to seperate files
Diffstat (limited to 'src/example/MoveCameraManualyScript.cpp')
-rw-r--r-- | src/example/MoveCameraManualyScript.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/example/MoveCameraManualyScript.cpp b/src/example/MoveCameraManualyScript.cpp new file mode 100644 index 0000000..0181333 --- /dev/null +++ b/src/example/MoveCameraManualyScript.cpp @@ -0,0 +1,22 @@ +#include "MoveCameraManualyScript.h" + +using namespace crepe; +using namespace std; + +void MoveCameraManualyScript::init() { + subscribe<KeyPressEvent>( + [this](const KeyPressEvent & ev) -> bool { return this->keypressed(ev); }); +} + +bool MoveCameraManualyScript::keypressed(const KeyPressEvent & event) { + if (event.key == Keycode::RIGHT) { + Transform & cam = this->get_components_by_name<Transform>("camera").front(); + cam.position.x += 100; + return true; + } else if (event.key == Keycode::LEFT) { + Transform & cam = this->get_components_by_name<Transform>("camera").front(); + cam.position.x -= 100; + return true; + } + return false; +} |