From b8acb539a3580bf0665fe435c55f33ba16cb507e Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 8 Jan 2025 09:58:34 +0100 Subject: WIP --- game/prefab/ZapperPoolScript.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'game/prefab') 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 #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 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() { -- cgit v1.2.3