From 160ba5a2d9ffafca45826a63461cbaa2ffa1b92d Mon Sep 17 00:00:00 2001 From: Benedikt Galbavy Date: Mon, 24 Jun 2024 22:38:01 +0200 Subject: [PATCH] #66 removed UI elements from HealthComponent --- include/HealthComponent.h | 4 +--- src/HealthComponent.cpp | 46 +-------------------------------------- 2 files changed, 2 insertions(+), 48 deletions(-) diff --git a/include/HealthComponent.h b/include/HealthComponent.h index 1d57330..930e5d3 100644 --- a/include/HealthComponent.h +++ b/include/HealthComponent.h @@ -10,7 +10,7 @@ class HealthComponent : public Component { public: - HealthComponent(int health, Direction side, std::string healthTexture) : health(health), side(side), healthTexture(healthTexture) {} + HealthComponent(int health) : health(health) {} ~HealthComponent() {} void modifyHealth(int health = -1); @@ -26,6 +26,4 @@ public: private: int health; - Direction side; - std::string healthTexture; }; \ No newline at end of file diff --git a/src/HealthComponent.cpp b/src/HealthComponent.cpp index 6294e97..ed39629 100644 --- a/src/HealthComponent.cpp +++ b/src/HealthComponent.cpp @@ -6,58 +6,14 @@ #include void HealthComponent::init() -{ - refreshHearts(); -} +{} void HealthComponent::modifyHealth(int health) { this->health += health; - this->refreshHearts(); } void HealthComponent::setHealth(int health) { this->health = health; - this->refreshHearts(); -} - -void HealthComponent::refreshHearts() -{ - // clear hearts if exist - for (auto& heart : this->entity->getManager().getGroup((size_t) Entity::GroupLabel::HEARTS)) { - if (heart->getTeam() == this->entity->getTeam()) { - heart->destroy(); - } - } - - int x; //starting position for first health icon - - if(side == Direction::LEFT) { - x = 10; - } else { - x = 730; - } - - for(int i = 0; i < health; i++) { - - //checks for player side - if (side == Direction::LEFT) { - createHeartComponents(x); - x += 50; - continue; - } - - createHeartComponents(x); - x -= 50; - } -} - -void HealthComponent::createHeartComponents(int x) -{ - auto& heart(this->entity->getManager().addEntity()); - heart.addComponent(x,5,2); - heart.addComponent(this->healthTexture.data()); - heart.addGroup((size_t)Entity::GroupLabel::HEARTS); - heart.setTeam(this->entity->getTeam()); } \ No newline at end of file