aboutsummaryrefslogtreecommitdiff
path: root/game/MoveCameraManualyScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/MoveCameraManualyScript.cpp')
-rw-r--r--game/MoveCameraManualyScript.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/game/MoveCameraManualyScript.cpp b/game/MoveCameraManualyScript.cpp
new file mode 100644
index 0000000..9d75a75
--- /dev/null
+++ b/game/MoveCameraManualyScript.cpp
@@ -0,0 +1,23 @@
+#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;
+}