diff --git a/sources/Component/Controllable/ControllableComponent.hpp b/sources/Component/Controllable/ControllableComponent.hpp index 8376d43f..f8c21743 100644 --- a/sources/Component/Controllable/ControllableComponent.hpp +++ b/sources/Component/Controllable/ControllableComponent.hpp @@ -22,6 +22,8 @@ namespace BBM bool bomb = false; //! @brief input value for pause bool pause = false; + //! @brief The speed applied to every controllable entities. + float speed = .25f; //! @inherit WAL::Component *clone(WAL::Entity &entity) const override; diff --git a/sources/Items/Bonus.cpp b/sources/Items/Bonus.cpp index dd6337c0..5ba73d6b 100644 --- a/sources/Items/Bonus.cpp +++ b/sources/Items/Bonus.cpp @@ -3,6 +3,7 @@ // #include +#include #include "Component/Movable/MovableComponent.hpp" #include "Bonus.hpp" #include "Component/BombHolder/BombHolderComponent.hpp" @@ -10,6 +11,8 @@ namespace BBM { void Bonus::BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { + if (bonus.shouldDelete()) + return; if (player.hasComponent()) { auto &bombHolder = player.getComponent(); bombHolder.maxBombCount++; @@ -18,6 +21,8 @@ namespace BBM { void Bonus::DamageIncreasedBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { + if (bonus.shouldDelete()) + return; if (player.hasComponent()) { auto &bombHolder = player.getComponent(); bombHolder.damage++; @@ -26,6 +31,8 @@ namespace BBM { void Bonus::ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { + if (bonus.shouldDelete()) + return; if (player.hasComponent()) { auto &bombHolder = player.getComponent(); bombHolder.explosionRadius++; @@ -34,14 +41,18 @@ namespace BBM { void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { + if (bonus.shouldDelete()) + return; if (!player.hasComponent()) return; - auto &movable = player.getComponent(); - movable.addForce(Vector3f(1, 0, 1)); + auto &controllable = player.getComponent(); + controllable.speed += 0.02f; } void Bonus::IgnoreWallsBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { + if (bonus.shouldDelete()) + return; if (player.hasComponent()) { auto &bombHolder = player.getComponent(); std::cout << "Explosion is supposed to pass through walls here" << std::endl; diff --git a/sources/System/Controllable/ControllableSystem.cpp b/sources/System/Controllable/ControllableSystem.cpp index f14c46b3..16c82d82 100644 --- a/sources/System/Controllable/ControllableSystem.cpp +++ b/sources/System/Controllable/ControllableSystem.cpp @@ -18,7 +18,7 @@ namespace BBM { auto &controllable = entity.get(); auto &movable = entity.get(); - Vector2f move = controllable.move.normalized() * ControllableSystem::speed; + Vector2f move = controllable.move.normalized() * controllable.speed; movable.addForce(Vector3f(move.x, controllable.jump, move.y)); } diff --git a/sources/System/Controllable/ControllableSystem.hpp b/sources/System/Controllable/ControllableSystem.hpp index 25a9e837..6648bbb3 100644 --- a/sources/System/Controllable/ControllableSystem.hpp +++ b/sources/System/Controllable/ControllableSystem.hpp @@ -15,9 +15,6 @@ namespace BBM class ControllableSystem : public WAL::System { public: - //! @brief The speed applied to every controllable entities. - static constexpr const float speed = .25f; - //! @inherit void onFixedUpdate(WAL::ViewEntity &entity) override; diff --git a/sources/System/Health/HealthSystem.cpp b/sources/System/Health/HealthSystem.cpp index 85fa2f0f..01e3f433 100644 --- a/sources/System/Health/HealthSystem.cpp +++ b/sources/System/Health/HealthSystem.cpp @@ -63,7 +63,7 @@ namespace BBM auto &position = entity.get(); if (health.getHealthPoint() == 0) { - if (entity->hasComponent()) { + if (entity->hasComponent() && !entity->shouldDelete()) { auto &bonus = entity->getComponent(); auto bonusType = bonus.getRandomBonusType(); this->_createBonus(position.position, bonusType, bonus.disappearTimer);