From fdcea71fcd0ec2228efef29d9e46fa0a3ee33ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Wed, 9 Jun 2021 17:43:38 +0200 Subject: [PATCH] fixing keyboard (he was switching between a and d) --- .../Collision/CollisionComponent.hpp | 6 ++++ sources/Items/Bonus.cpp | 1 - sources/Map/Map.cpp | 29 ++++++++++--------- sources/Map/Map.hpp | 6 ++-- sources/System/Collision/CollisionSystem.cpp | 2 +- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/sources/Component/Collision/CollisionComponent.hpp b/sources/Component/Collision/CollisionComponent.hpp index 06878a76..e4244a7a 100644 --- a/sources/Component/Collision/CollisionComponent.hpp +++ b/sources/Component/Collision/CollisionComponent.hpp @@ -23,8 +23,14 @@ namespace BBM }; //! @brief onCollide functions to be called + //! @param first self + //! @param second the entity you collided + //! @param third the collision axis (to know which axis collided) WAL::Callback onCollide; //! @brief onCollided functions to be called + //! @param first the entity that collided you + //! @param second self + //! @param third the collision axis (to know which axis collided) WAL::Callback onCollided; //! @brief Bound size on all axis Vector3f bound; diff --git a/sources/Items/Bonus.cpp b/sources/Items/Bonus.cpp index 60365e05..3f9ec489 100644 --- a/sources/Items/Bonus.cpp +++ b/sources/Items/Bonus.cpp @@ -37,7 +37,6 @@ namespace BBM { void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) { - std::cout << "soeed" << std::endl; if (bonus.shouldDelete()) return; auto *controllable = player.tryGetComponent(); diff --git a/sources/Map/Map.cpp b/sources/Map/Map.cpp index 5772e298..0554b742 100644 --- a/sources/Map/Map.cpp +++ b/sources/Map/Map.cpp @@ -17,10 +17,14 @@ using namespace std::chrono_literals; namespace BBM { - void MapGenerator::wallCollide(WAL::Entity &entity, - const WAL::Entity &wall, - CollisionComponent::CollidedAxis collidedAxis) + void MapGenerator::wallCollided(WAL::Entity &entity, + 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) @@ -57,10 +61,9 @@ namespace BBM entity.scheduleDeletion(); }) .addComponent(position.y) - .addComponent(func[bonusType - 1], [](WAL::Entity &bonus, const WAL::Entity &player, CollisionComponent::CollidedAxis axis) { + .addComponent([](WAL::Entity &bonus, const WAL::Entity &player, CollisionComponent::CollidedAxis axis) { bonus.scheduleDeletion(); - std::cout << "called" << std::endl; - }, 0.5, .5) + }, func[bonusType - 1], 0.5, .5) .addComponent(5s, [](WAL::Entity &bonus, WAL::Wal &wal){ bonus.scheduleDeletion(); }) @@ -93,7 +96,7 @@ namespace BBM .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, 0.25, .75) + &MapGenerator::wallCollided, 0.25, .75) .addComponent(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePng)); } @@ -111,7 +114,7 @@ namespace BBM .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) + &MapGenerator::wallCollided, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) .addComponent(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(width + 3, 1, 1)); @@ -120,7 +123,7 @@ namespace BBM .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) + &MapGenerator::wallCollided, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) .addComponent(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(width + 3, 1, 1)); @@ -129,7 +132,7 @@ namespace BBM .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) + &MapGenerator::wallCollided, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) .addComponent(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(1, 1, height + 1)); @@ -137,7 +140,7 @@ namespace BBM .addComponent(Vector3f(-1, 0, height / 2)) .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) + &MapGenerator::wallCollided, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) .addComponent(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(1, 1, height + 1)); @@ -189,7 +192,7 @@ namespace BBM .addComponent(1, &MapGenerator::wallDestroyed) .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, 0.25, .75) + &MapGenerator::wallCollided, 0.25, .75) .addComponent(breakableObj, std::make_pair(MAP_DIFFUSE, breakablePng)); } @@ -225,7 +228,7 @@ namespace BBM .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, 0.25, .75) + &MapGenerator::wallCollided, 0.25, .75) .addComponent(UnbreakableObj, std::make_pair(MAP_DIFFUSE, UnbreakablePng)); } diff --git a/sources/Map/Map.hpp b/sources/Map/Map.hpp index ea8da96c..8fb6da1c 100644 --- a/sources/Map/Map.hpp +++ b/sources/Map/Map.hpp @@ -155,9 +155,9 @@ namespace BBM static const std::string secondFloorHolePath; public: - static void wallCollide(WAL::Entity &entity, - const WAL::Entity &wall, - CollisionComponent::CollidedAxis collidedAxis); + static void wallCollided(WAL::Entity &entity, + const WAL::Entity &wall, + CollisionComponent::CollidedAxis collidedAxis); static void wallDestroyed(WAL::Entity &entity, WAL::Wal &wal); diff --git a/sources/System/Collision/CollisionSystem.cpp b/sources/System/Collision/CollisionSystem.cpp index bb12b32f..db68e3c0 100644 --- a/sources/System/Collision/CollisionSystem.cpp +++ b/sources/System/Collision/CollisionSystem.cpp @@ -69,7 +69,7 @@ namespace BBM collidedAxis += CollisionComponent::CollidedAxis::Z; } if (collidedAxis) { - colA.onCollide(other, entity, static_cast(collidedAxis)); + colA.onCollide(entity, other, static_cast(collidedAxis)); colB.onCollided(entity, other, static_cast(collidedAxis)); } }