diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-08 09:58:34 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-08 09:58:34 +0100 |
commit | b8acb539a3580bf0665fe435c55f33ba16cb507e (patch) | |
tree | 34665fbccaffef115876c2f6670fba0d70314e03 /game/prefab/ZapperPoolScript.cpp | |
parent | f8ffac3b14d41e7d1e43ffe64750d910ed333b0d (diff) |
WIP
Diffstat (limited to 'game/prefab/ZapperPoolScript.cpp')
-rw-r--r-- | game/prefab/ZapperPoolScript.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/game/prefab/ZapperPoolScript.cpp b/game/prefab/ZapperPoolScript.cpp index e42adc9..c6ce1e7 100644 --- a/game/prefab/ZapperPoolScript.cpp +++ b/game/prefab/ZapperPoolScript.cpp @@ -1,9 +1,11 @@ #include <crepe/api/Camera.h> #include "../Config.h" +#include "../Random.h" #include "ZapperPoolScript.h" #include "ZapperPoolSubScene.h" +#include "util/OptionalRef.h" using namespace crepe; using namespace std; @@ -24,9 +26,14 @@ void ZapperPoolScript::fixed_update(crepe::duration_t) { } void ZapperPoolScript::spawn_random() { + OptionalRef<ZapperObject> zapper = pool.get_next_zapper(); + if (!zapper) return; // pool exhausted + vec2 pos = this->get_camera_pos(); - logf(Log::DEBUG, "Spawning random zapper at {}", pos); + pos.y = Random::f(0.5, -0.5) * HALLWAY_HEIGHT; + zapper->place(pos, 0, Random::f(400, 200)); + logf(Log::DEBUG, "Spawning random zapper at {}", pos); } vec2 ZapperPoolScript::get_camera_pos() { |