From 2955cd76a76ab1efec35faf35e91b9236c9c8244 Mon Sep 17 00:00:00 2001 From: HENRY Benjamin Date: Wed, 9 Jun 2021 22:22:27 +0200 Subject: [PATCH] added a bandage to a huge wound (collisionsystem wasn't calling the two callbacks, just one, now it's still only one, but the bonuses are applied only if you're on them --- sources/Items/Bonus.cpp | 16 ++++++++-------- sources/Items/Bonus.hpp | 3 +-- sources/Map/Map.cpp | 4 ---- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/sources/Items/Bonus.cpp b/sources/Items/Bonus.cpp index 3f9ec489..47a5c2ba 100644 --- a/sources/Items/Bonus.cpp +++ b/sources/Items/Bonus.cpp @@ -12,35 +12,35 @@ namespace BBM { void Bonus::BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { - if (bonus.shouldDelete()) + if (bonus.shouldDelete() || axis != 7) return; auto *bombHolder = player.tryGetComponent(); - if (bombHolder == nullptr) + if (!bombHolder) return; bombHolder->maxBombCount++; } void Bonus::ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { - static int test = 0; - if (bonus.shouldDelete()) + if (bonus.shouldDelete() || axis != 7) return; auto *bombHolder = player.tryGetComponent(); auto *playerBonus = player.tryGetComponent(); - if (bombHolder == nullptr || playerBonus == nullptr) + if (!bombHolder || !playerBonus) return; if (bombHolder->explosionRadius <= 6) bombHolder->explosionRadius++; - std::cout << ++test << " Explosion radius : " << bombHolder->explosionRadius << std::endl; playerBonus->nextRangeBonusRate = playerBonus->rangeBonusRate; } void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { - if (bonus.shouldDelete()) + if (bonus.shouldDelete() || axis != 7) return; auto *controllable = player.tryGetComponent(); auto *playerBonus = player.tryGetComponent(); + if (!controllable || !playerBonus) + return; controllable->speed = 0.35f; playerBonus->nextSpeedBonusRate = playerBonus->speedBonusRate; } @@ -50,7 +50,7 @@ namespace BBM { double rnd = static_cast(std::rand()) / RAND_MAX; if (rnd < 0.8) - return (static_cast(std::rand() % (DAMAGEINC - 1) + 1)); + return (static_cast(std::rand() % (EXPLOSIONINC - 1) + 1)); return (NOTHING); } } \ No newline at end of file diff --git a/sources/Items/Bonus.hpp b/sources/Items/Bonus.hpp index 25fa182c..6c15efd4 100644 --- a/sources/Items/Bonus.hpp +++ b/sources/Items/Bonus.hpp @@ -34,8 +34,7 @@ namespace BBM { NOTHING, BOMBSTOCK, SPEEDUP, - EXPLOSIONINC, - DAMAGEINC + EXPLOSIONINC }; static BonusType getRandomBonusType(); diff --git a/sources/Map/Map.cpp b/sources/Map/Map.cpp index 0554b742..28242cc8 100644 --- a/sources/Map/Map.cpp +++ b/sources/Map/Map.cpp @@ -21,10 +21,6 @@ namespace BBM const WAL::Entity &wall, CollisionComponent::CollidedAxis collidedAxis) { - auto name = entity.getName(); - if (name == "Unbreakable Wall" || name == "Breakable Block") { - name = "salut"; - } auto *mov = entity.tryGetComponent(); if (!mov)