diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-07 13:04:49 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-07 13:04:49 +0100 |
commit | 6d69c8ef6b663bd6716b441cc7d01164c7e33dfc (patch) | |
tree | cbf6d4a4d7f099ca662bed00edc627212511a99e | |
parent | 87ae4d186ad64531e96fd3e121112f2787894295 (diff) |
more WIP zapperpool
-rw-r--r-- | game/GameScene.cpp | 4 | ||||
-rw-r--r-- | game/prefab/CMakeLists.txt | 1 | ||||
-rw-r--r-- | game/prefab/ZapperObject.cpp | 18 | ||||
-rw-r--r-- | game/prefab/ZapperObject.h | 1 | ||||
-rw-r--r-- | game/prefab/ZapperPoolScript.h | 8 | ||||
-rw-r--r-- | game/prefab/ZapperPoolSubScene.cpp | 13 | ||||
-rw-r--r-- | game/prefab/ZapperPoolSubScene.h | 21 |
7 files changed, 64 insertions, 2 deletions
diff --git a/game/GameScene.cpp b/game/GameScene.cpp index 1eefce1..698677b 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -23,7 +23,7 @@ #include "background/BackgroundSubScene.h" #include "player/PlayerSubScene.h" -#include "prefab/ZapperObject.h" +#include "prefab/ZapperPoolSubScene.h" using namespace crepe; using namespace std; @@ -69,7 +69,7 @@ void GameScene::load_scene() { }); ceiling.add_component<BoxCollider>(vec2(INFINITY, 200)); - ZapperObject {new_object("zapper", "zapper", vec2(800, 0))}; + ZapperPoolSubScene {*this}; GameObject start_game_script = new_object("start_game_script", "script", vec2(0, 0)); start_game_script.add_component<BehaviorScript>().set_script<StartGameScript>(); diff --git a/game/prefab/CMakeLists.txt b/game/prefab/CMakeLists.txt index 5f8ea6c..d77b9b1 100644 --- a/game/prefab/CMakeLists.txt +++ b/game/prefab/CMakeLists.txt @@ -1,4 +1,5 @@ target_sources(main PUBLIC ZapperObject.cpp + ZapperPoolSubScene.cpp ) diff --git a/game/prefab/ZapperObject.cpp b/game/prefab/ZapperObject.cpp index 4055ac4..3c70d04 100644 --- a/game/prefab/ZapperObject.cpp +++ b/game/prefab/ZapperObject.cpp @@ -81,6 +81,7 @@ ZapperObject::ZapperObject(crepe::GameObject && base) })}, collider {add_component<BoxCollider>(vec2(0, 0))} { this->place(this->transform.position, 0, 300); + this->set_active(false); } void ZapperObject::place(const crepe::vec2 & position, float rotation, float length) { @@ -98,3 +99,20 @@ void ZapperObject::place(const crepe::vec2 & position, float rotation, float len this->collider.dimensions = offset.rotate(rotation) * 2 + vec2(30, 30) * SCALE; } + +void ZapperObject::set_active(bool active) { + this->sprite.orb_start.active = active; + this->sprite.orb_end.active = active; + this->sprite.glow_start.active = active; + this->sprite.glow_end.active = active; + this->sprite.beam.active = active; + + this->animator.orb_start.active = active; + this->animator.orb_end.active = active; + this->animator.glow_start.active = active; + this->animator.glow_end.active = active; + + this->body.active = active; + this->collider.active = active; +} + diff --git a/game/prefab/ZapperObject.h b/game/prefab/ZapperObject.h index c43af67..9f4e4a1 100644 --- a/game/prefab/ZapperObject.h +++ b/game/prefab/ZapperObject.h @@ -34,4 +34,5 @@ private: public: void place(const crepe::vec2 & position, float rotation, float length); + void set_active(bool active); }; diff --git a/game/prefab/ZapperPoolScript.h b/game/prefab/ZapperPoolScript.h new file mode 100644 index 0000000..79f9a89 --- /dev/null +++ b/game/prefab/ZapperPoolScript.h @@ -0,0 +1,8 @@ +#pragma once + +#include <crepe/api/Script.h> + +class ZapperPoolScript : public crepe::Script { + +}; + diff --git a/game/prefab/ZapperPoolSubScene.cpp b/game/prefab/ZapperPoolSubScene.cpp new file mode 100644 index 0000000..578688a --- /dev/null +++ b/game/prefab/ZapperPoolSubScene.cpp @@ -0,0 +1,13 @@ +#include "ZapperPoolSubScene.h" + +using namespace crepe; +using namespace std; + +ZapperPoolSubScene::ZapperPoolSubScene(Scene & scene) + : controller { scene.new_object("controller") } { + for (size_t i = 0; i < this->POOL_SIZE; i++) + zappers.emplace_back(scene.new_object("zapper")); + + +} + diff --git a/game/prefab/ZapperPoolSubScene.h b/game/prefab/ZapperPoolSubScene.h new file mode 100644 index 0000000..79598ce --- /dev/null +++ b/game/prefab/ZapperPoolSubScene.h @@ -0,0 +1,21 @@ +#pragma once + +#include <vector> + +#include <crepe/api/Scene.h> +#include <crepe/api/GameObject.h> + +#include "ZapperObject.h" + +class ZapperPoolSubScene { +public: + ZapperPoolSubScene(crepe::Scene & scene); + +public: + crepe::GameObject controller; + std::vector<ZapperObject> zappers; + +private: + static constexpr size_t POOL_SIZE = 4; + +}; |