aboutsummaryrefslogtreecommitdiff
path: root/game/prefab/ZapperPoolScript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/prefab/ZapperPoolScript.cpp')
-rw-r--r--game/prefab/ZapperPoolScript.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/game/prefab/ZapperPoolScript.cpp b/game/prefab/ZapperPoolScript.cpp
new file mode 100644
index 0000000..00dd213
--- /dev/null
+++ b/game/prefab/ZapperPoolScript.cpp
@@ -0,0 +1,33 @@
+#include <crepe/api/Camera.h>
+
+#include "../Config.h"
+
+#include "ZapperPoolScript.h"
+#include "ZapperPoolSubScene.h"
+
+using namespace crepe;
+using namespace std;
+
+ZapperPoolScript::ZapperPoolScript(ZapperPoolSubScene & pool) : pool(pool) {}
+
+void ZapperPoolScript::init() {
+ subscribe<CreateZapperEvent>([this](const CreateZapperEvent &) {
+ this->spawn_random();
+ return true;
+ });
+}
+
+void ZapperPoolScript::spawn_random() {
+ vec2 pos = this->get_camera_pos();
+ logf(Log::DEBUG, "Spawning random zappers at {}", pos);
+
+}
+
+vec2 ZapperPoolScript::get_camera_pos() {
+ Transform & transform = get_components_by_name<Transform>(CAMERA_NAME).back();
+ Camera & camera = get_components_by_name<Camera>(CAMERA_NAME).back();
+
+ // right middle edge position
+ return transform.position + vec2(camera.viewport_size.x / 2, 0);
+}
+