diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b5fcb13..1c1acedd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,7 @@ set(SOURCES sources/System/EndCondition/EndConditionSystem.hpp sources/System/EndCondition/EndConditionSystem.cpp sources/Runner/LobbyScene.cpp + sources/Runner/ScoreScene.cpp ) add_executable(bomberman sources/main.cpp diff --git a/sources/Runner/Runner.hpp b/sources/Runner/Runner.hpp index dd225e1e..e0dcee97 100644 --- a/sources/Runner/Runner.hpp +++ b/sources/Runner/Runner.hpp @@ -59,6 +59,11 @@ namespace BBM //! @brief load all data related to splash screen static std::shared_ptr loadSplashScreenScene(); + //! @brief load all data related to score scene screen + //! @param gameScene scene containing players (to know the scores) + static std::shared_ptr loadScoreScene(WAL::Scene &gameScene); + + //! @brief loads all scenes in the game state static void loadScenes(); }; diff --git a/sources/Runner/ScoreScene.cpp b/sources/Runner/ScoreScene.cpp new file mode 100644 index 00000000..b65176c1 --- /dev/null +++ b/sources/Runner/ScoreScene.cpp @@ -0,0 +1,50 @@ + +#include +#include "Runner.hpp" +#include +#include "Component/Button/ButtonComponent.hpp" +#include "Component/Music/MusicComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Sound/SoundComponent.hpp" +#include "Drawables/Texture.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadScoreScene(WAL::Scene &gameScene) + { + auto scene = std::make_shared(); + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + + scene->addEntity("Control entity") + .addComponent("assets/musics/music_result.ogg") + .addComponent(sounds); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("back to main menu") + .addComponent(10, 1080 - 85, 0) + .addComponent("assets/buttons/button_back.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back_hovered.png"); + }); + return scene; + } +} \ No newline at end of file