diff options
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() { |