mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-23 14:58:22 +00:00
Update speedup bonus & fixing one bug (double bonus/...)
This commit is contained in:
@@ -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;
|
||||
|
||||
+13
-2
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include <Component/Collision/CollisionComponent.hpp>
|
||||
#include <Component/Controllable/ControllableComponent.hpp>
|
||||
#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<BombHolderComponent>()) {
|
||||
auto &bombHolder = player.getComponent<BombHolderComponent>();
|
||||
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<BombHolderComponent>()) {
|
||||
auto &bombHolder = player.getComponent<BombHolderComponent>();
|
||||
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<BombHolderComponent>()) {
|
||||
auto &bombHolder = player.getComponent<BombHolderComponent>();
|
||||
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<MovableComponent>())
|
||||
return;
|
||||
auto &movable = player.getComponent<MovableComponent>();
|
||||
movable.addForce(Vector3f(1, 0, 1));
|
||||
auto &controllable = player.getComponent<ControllableComponent>();
|
||||
controllable.speed += 0.02f;
|
||||
}
|
||||
|
||||
void Bonus::IgnoreWallsBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis)
|
||||
{
|
||||
if (bonus.shouldDelete())
|
||||
return;
|
||||
if (player.hasComponent<BombHolderComponent>()) {
|
||||
auto &bombHolder = player.getComponent<BombHolderComponent>();
|
||||
std::cout << "Explosion is supposed to pass through walls here" << std::endl;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace BBM
|
||||
{
|
||||
auto &controllable = entity.get<ControllableComponent>();
|
||||
auto &movable = entity.get<MovableComponent>();
|
||||
Vector2f move = controllable.move.normalized() * ControllableSystem::speed;
|
||||
Vector2f move = controllable.move.normalized() * controllable.speed;
|
||||
|
||||
movable.addForce(Vector3f(move.x, controllable.jump, move.y));
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@ namespace BBM
|
||||
class ControllableSystem : public WAL::System<ControllableComponent, MovableComponent>
|
||||
{
|
||||
public:
|
||||
//! @brief The speed applied to every controllable entities.
|
||||
static constexpr const float speed = .25f;
|
||||
|
||||
//! @inherit
|
||||
void onFixedUpdate(WAL::ViewEntity<ControllableComponent, MovableComponent> &entity) override;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace BBM
|
||||
auto &position = entity.get<PositionComponent>();
|
||||
|
||||
if (health.getHealthPoint() == 0) {
|
||||
if (entity->hasComponent<BonusComponent>()) {
|
||||
if (entity->hasComponent<BonusComponent>() && !entity->shouldDelete()) {
|
||||
auto &bonus = entity->getComponent<BonusComponent>();
|
||||
auto bonusType = bonus.getRandomBonusType();
|
||||
this->_createBonus(position.position, bonusType, bonus.disappearTimer);
|
||||
|
||||
Reference in New Issue
Block a user