create blank scene for score scene

This commit is contained in:
arthur.jamet
2021-06-15 11:16:32 +02:00
parent 5d918e740e
commit 2ec012c567
3 changed files with 56 additions and 0 deletions

View File

@@ -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

View File

@@ -59,6 +59,11 @@ namespace BBM
//! @brief load all data related to splash screen
static std::shared_ptr<WAL::Scene> loadSplashScreenScene();
//! @brief load all data related to score scene screen
//! @param gameScene scene containing players (to know the scores)
static std::shared_ptr<WAL::Scene> loadScoreScene(WAL::Scene &gameScene);
//! @brief loads all scenes in the game state
static void loadScenes();
};

View File

@@ -0,0 +1,50 @@
#include <Wal.hpp>
#include "Runner.hpp"
#include <map>
#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<WAL::Scene> Runner::loadScoreScene(WAL::Scene &gameScene)
{
auto scene = std::make_shared<WAL::Scene>();
static const std::map<SoundComponent::SoundIndex, std::string> sounds = {
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
};
scene->addEntity("Control entity")
.addComponent<MusicComponent>("assets/musics/music_result.ogg")
.addComponent<SoundComponent>(sounds);
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("back to main menu")
.addComponent<PositionComponent>(10, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
})
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_back.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_back_hovered.png");
});
return scene;
}
}