From dc8140877c1ae638285d812035473591a1814ce7 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Thu, 9 Jan 2025 16:06:45 +0100 Subject: enemy death working --- game/enemy/EnemyPool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'game/enemy/EnemyPool.h') diff --git a/game/enemy/EnemyPool.h b/game/enemy/EnemyPool.h index f4d6765..ec96ac4 100644 --- a/game/enemy/EnemyPool.h +++ b/game/enemy/EnemyPool.h @@ -7,5 +7,5 @@ public: void create_enemies(crepe::Scene & scn); private: - static constexpr int MAXIMUM_AMOUNT = 10; + static constexpr int MAXIMUM_AMOUNT = 7; }; -- cgit v1.2.3 From cb17c2aad3ca8c89d0f6d8305ba4f3a5c3c2a971 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Fri, 10 Jan 2025 10:19:02 +0100 Subject: added to config enemy_pool_max --- game/enemy/BattleScript.cpp | 4 ++-- game/enemy/EnemyConfig.h | 1 + game/enemy/EnemyPool.cpp | 2 +- game/enemy/EnemyPool.h | 4 +--- 4 files changed, 5 insertions(+), 6 deletions(-) (limited to 'game/enemy/EnemyPool.h') diff --git a/game/enemy/BattleScript.cpp b/game/enemy/BattleScript.cpp index 7bea79a..798cbb9 100644 --- a/game/enemy/BattleScript.cpp +++ b/game/enemy/BattleScript.cpp @@ -1,5 +1,5 @@ #include "BattleScript.h" -#include "../enemy/EnemyConfig.h" +#include "EnemyConfig.h" #include "EnemyScript.h" #include "api/Transform.h" #include @@ -41,7 +41,7 @@ void BattleScript::spawn_enemies(int amount) { RefVector enemy_ai = this->get_components_by_tag("enemy"); std::uniform_real_distribution dist(70, 150); int spawned = 0; - for (int i = 0; i < 7; i++) { + for (int i = 0; i < ENEMY_POOL_MAX; i++) { AI & ai = enemy_ai[i]; Transform & enemy_transform = this->get_components_by_id(ai.game_object_id).front(); diff --git a/game/enemy/EnemyConfig.h b/game/enemy/EnemyConfig.h index f7b660a..f9fb469 100644 --- a/game/enemy/EnemyConfig.h +++ b/game/enemy/EnemyConfig.h @@ -5,3 +5,4 @@ // static constexpr crepe::vec2 PLAYER_BULLET_POOL_LOCATION = {0, -850}; static constexpr crepe::vec2 ENEMY_BULLET_POOL_LOCATION = {0, -750}; static constexpr crepe::vec2 ENEMY_POOL_LOCATION = {0, -650}; +static constexpr int ENEMY_POOL_MAX = 12; diff --git a/game/enemy/EnemyPool.cpp b/game/enemy/EnemyPool.cpp index a7179bf..135fc35 100644 --- a/game/enemy/EnemyPool.cpp +++ b/game/enemy/EnemyPool.cpp @@ -4,7 +4,7 @@ using namespace std; void EnemyPool::create_enemies(crepe::Scene & scn) { EnemySubScene enemy; int amount = 0; - while (amount < this->MAXIMUM_AMOUNT) { + while (amount < ENEMY_POOL_MAX) { amount = enemy.create(scn, amount); } } diff --git a/game/enemy/EnemyPool.h b/game/enemy/EnemyPool.h index ec96ac4..25f7fb8 100644 --- a/game/enemy/EnemyPool.h +++ b/game/enemy/EnemyPool.h @@ -1,11 +1,9 @@ #pragma once #include - +#include "EnemyConfig.h" class EnemyPool { public: void create_enemies(crepe::Scene & scn); -private: - static constexpr int MAXIMUM_AMOUNT = 7; }; -- cgit v1.2.3 From 22d77b99d700e6317a7432e475330e4bb3c9745d Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Fri, 10 Jan 2025 11:11:53 +0100 Subject: make format --- game/enemy/EnemyPool.h | 3 +-- game/enemy/EnemyScript.cpp | 8 ++++---- game/enemy/EnemySubScene.cpp | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'game/enemy/EnemyPool.h') diff --git a/game/enemy/EnemyPool.h b/game/enemy/EnemyPool.h index 25f7fb8..cfd0b1c 100644 --- a/game/enemy/EnemyPool.h +++ b/game/enemy/EnemyPool.h @@ -1,9 +1,8 @@ #pragma once -#include #include "EnemyConfig.h" +#include class EnemyPool { public: void create_enemies(crepe::Scene & scn); - }; diff --git a/game/enemy/EnemyScript.cpp b/game/enemy/EnemyScript.cpp index 77c9bd2..24583c0 100644 --- a/game/enemy/EnemyScript.cpp +++ b/game/enemy/EnemyScript.cpp @@ -99,7 +99,7 @@ bool EnemyScript::spawn_enemy(const SpawnEnemyEvent & e) { Transform & transform = this->get_component(); Camera & camera = this->get_components_by_name("camera").front(); Transform & cam_transform = this->get_components_by_name("camera").front(); - Rigidbody& rb = this->get_component(); + Rigidbody & rb = this->get_component(); rb.data.collision_layers = {COLL_LAY_BOT_TOP, COLL_LAY_PLAYER_BULLET}; rb.data.collision_layer = COLL_LAY_ENEMY; vec2 half_screen = camera.viewport_size / 2; @@ -139,10 +139,10 @@ bool EnemyScript::on_collide(const CollisionEvent & e) { //Sprite& sprite; set_hit_blink(true); if (health <= 0) { - this->death(); - } + this->death(); + } } - + //body_animator.play(); return false; diff --git a/game/enemy/EnemySubScene.cpp b/game/enemy/EnemySubScene.cpp index d1117d8..c6aecec 100644 --- a/game/enemy/EnemySubScene.cpp +++ b/game/enemy/EnemySubScene.cpp @@ -53,7 +53,7 @@ int EnemySubScene::create(Scene & scn, int enemy_counter) { } ); body_animator.pause(); - + Asset enemy_head_asset {"asset/workers/worker2Head.png"}; Sprite & enemy_head_sprite = enemy.add_component( enemy_head_asset, -- cgit v1.2.3