diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 6950f26d..bcd3bd71 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -70,6 +70,8 @@ namespace BBM break; } } + if (gameState.nextScene != GameState::SceneID::GameScene) + engine.getSystem().hasEnded = false; } if (gameState.nextScene == gameState.currentScene) return; diff --git a/sources/System/Renderer/CameraSystem.cpp b/sources/System/Renderer/CameraSystem.cpp index 26962c2b..fdddc5c4 100644 --- a/sources/System/Renderer/CameraSystem.cpp +++ b/sources/System/Renderer/CameraSystem.cpp @@ -18,16 +18,11 @@ namespace BBM : System(wal) {} - bool CameraSystem::introAnimation(WAL::ViewEntity &entity, bool restart) + bool CameraSystem::introAnimation(WAL::ViewEntity &entity) { auto &pos = entity.get(); static Vector3f posTarget(8, 25, 7); - static bool hasEnded = false; - if (restart) { - hasEnded = false; - return (false); - } if (hasEnded) return true; if (pos.position.distance(posTarget) < 4) { @@ -43,13 +38,12 @@ namespace BBM .addComponent("", 60, RAY::Vector2(), ORANGE); for (WAL::Entity &player : this->_wal.getScene()->view>()) player.getComponent().disabled = false; - return (true); + return true; } auto &cam = entity.get(); - pos.position += (posTarget - pos.position) / 100; - return (false); + return false; } void CameraSystem::onUpdate(WAL::ViewEntity &entity, @@ -68,8 +62,6 @@ namespace BBM for (auto &[entity, pos, _] : this->_wal.getScene()->view>()) { playerPos.emplace_back(pos.position); } - if (!playerPos.empty()) - introAnimation(entity, true); if (playerPos.size() == 1) newCameraPos = playerPos[0]; for (int i = 0; i < playerPos.size(); i++) diff --git a/sources/System/Renderer/CameraSystem.hpp b/sources/System/Renderer/CameraSystem.hpp index ce3a804f..22bf87e0 100644 --- a/sources/System/Renderer/CameraSystem.hpp +++ b/sources/System/Renderer/CameraSystem.hpp @@ -16,11 +16,14 @@ namespace BBM class CameraSystem : public WAL::System { public: + //! @brief A boolean indicating if the intro's animation has ended. + bool hasEnded = false; + //! @inherit void onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds) override; //! @brief introduciton animation when entering gameScene - bool introAnimation(WAL::ViewEntity &entity, bool restart = false); + bool introAnimation(WAL::ViewEntity &entity); //! @brief ctor CameraSystem(WAL::Wal &wal);