From 6570bf598a3b3768fe34827529df5ea0b4b26f0e Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 20 Dec 2024 12:52:15 +0100 Subject: move game files --- game/MoveCameraManualyScript.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 game/MoveCameraManualyScript.cpp (limited to 'game/MoveCameraManualyScript.cpp') diff --git a/game/MoveCameraManualyScript.cpp b/game/MoveCameraManualyScript.cpp new file mode 100644 index 0000000..0181333 --- /dev/null +++ b/game/MoveCameraManualyScript.cpp @@ -0,0 +1,22 @@ +#include "MoveCameraManualyScript.h" + +using namespace crepe; +using namespace std; + +void MoveCameraManualyScript::init() { + subscribe( + [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("camera").front(); + cam.position.x += 100; + return true; + } else if (event.key == Keycode::LEFT) { + Transform & cam = this->get_components_by_name("camera").front(); + cam.position.x -= 100; + return true; + } + return false; +} -- cgit v1.2.3