Skip to content

Commit

Permalink
fixed invaders game player life entity destroy logic
Browse files Browse the repository at this point in the history
  • Loading branch information
denyskryvytskyi committed Feb 21, 2024
1 parent 3b8505d commit 36585cf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
Binary file added .github/demo/invaders.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Games/Invaders/src/Invaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ class PlayerBehavior : public elv::ecs::IBehavior {
if (m_shieldEntity != elv::ecs::INVALID_ENTITY_ID) {
p_Scene->DestroyEntity(m_shieldEntity);
}

auto& playerComponent = GetComponent<PlayerComponent>();
for (const auto lifeEntity : playerComponent.lifeEntities) {
p_Scene->DestroyEntity(lifeEntity);
}
}

void OnUpdate(float dt) override
Expand Down
2 changes: 1 addition & 1 deletion Games/Pong/src/Pong.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class PaddleBehavior : public elv::ecs::IBehavior {
};

struct BallComponent {
lia::vec3 velocity { 0.0f, 0.0f, 0.0f };
float speed = ballSpeed;
lia::vec3 velocity { 0.0f, 0.0f, 0.0f };
};

class BallBehavior : public elv::ecs::IBehavior {
Expand Down
4 changes: 2 additions & 2 deletions Games/Pong/src/Pong.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Pong : public elv::Application {

private:
Player m_players[2];
elv::ecs::Entity m_ball;
elv::ecs::Entity m_winnerEntity;
elv::ecs::Entity m_ball { elv::ecs::INVALID_ENTITY_ID };
elv::ecs::Entity m_winnerEntity { elv::ecs::INVALID_ENTITY_ID };
GameState m_gameState { GameState::Menu };

// text
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ Firstly you need to install [cmake](https://cmake.org/) 3.10+ version (3.21+ for

## Demo
#### Space Invaders
<b>Quick demo</b>
<img src=".github/demo/invaders.gif">
<b>Full demo</b>
https://github.com/denyskryvytskyi/ElvenEngine/assets/25298585/f0d32c8b-1ed2-44e3-9c93-a781f3da4203

#### Ping-pong
Expand Down

0 comments on commit 36585cf

Please sign in to comment.