add how to play scene

This commit is contained in:
arthur.jamet
2021-06-15 14:59:45 +02:00
parent 1ff0a8bc5d
commit af599fac0f
6 changed files with 88 additions and 1 deletions
+1
View File
@@ -135,6 +135,7 @@ set(SOURCES
sources/Runner/SettingsMenuScene.cpp
sources/Runner/CreditScene.cpp
sources/Runner/LobbyScene.cpp
sources/Runner/HowToPlayScene.cpp
)
add_executable(bomberman
sources/main.cpp
+1
View File
@@ -26,6 +26,7 @@ namespace BBM
LobbyScene,
TitleScreenScene,
CreditScene,
HowToPlayScene,
};
+81
View File
@@ -0,0 +1,81 @@
#include <memory>
#include <Wal.hpp>
#include "Runner.hpp"
#include <map>
#include "Component/Music/MusicComponent.hpp"
#include "Component/Sound/SoundComponent.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "Component/Keyboard/KeyboardComponent.hpp"
#include "Component/Renderer/Drawable2DComponent.hpp"
#include "Component/Button/ButtonComponent.hpp"
#include "Drawables/2D/Text.hpp"
namespace RAY2D = RAY::Drawables::Drawables2D;
namespace BBM
{
std::shared_ptr<WAL::Scene> Runner::loadHowToPlayScene()
{
auto scene = std::make_shared<WAL::Scene>();
static const std::map<SoundComponent::SoundIndex, std::string> sounds = {
{SoundComponent::JUMP, "assets/sounds/click.ogg"}
};
addMenuControl(*scene);
scene->addEntity("Control entity")
.addComponent<MusicComponent>("assets/musics/music_player_select.ogg")
.addComponent<SoundComponent>(sounds);
scene->addEntity("background")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY::Texture>("assets/plain_menu_background.png");
scene->addEntity("scene title text")
.addComponent<PositionComponent>(1920 / 3, 100, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("How To Play?", 120, RAY::Vector2(), ORANGE);
scene->addEntity("select text")
.addComponent<PositionComponent>(1920 / 8, 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Select:", 60, RAY::Vector2(), ORANGE);
scene->addEntity("select")
.addComponent<PositionComponent>(1920 / 7, 1080 / 2.5, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Space/A Button", 35, RAY::Vector2(), BLACK);
scene->addEntity("change skin text")
.addComponent<PositionComponent>(1920 / 8, 1080 / 2, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Change Skin/Drop Bomb:", 60, RAY::Vector2(), ORANGE);
scene->addEntity("change skin")
.addComponent<PositionComponent>(1920 / 7, 1080 / 1.75, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("E/B Button", 35, RAY::Vector2(), BLACK);
scene->addEntity("move text")
.addComponent<PositionComponent>(1920 / 1.75, 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Move:", 60, RAY::Vector2(), ORANGE);
scene->addEntity("move")
.addComponent<PositionComponent>(1920 / 1.75, 1080 / 2.5, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Q-Z-S-D/Arrow/Joystick", 35, RAY::Vector2(), BLACK);
scene->addEntity("back text")
.addComponent<PositionComponent>(1920 / 1.75, 1080 / 2, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Back/Pause:", 60, RAY::Vector2(), ORANGE);
scene->addEntity("back")
.addComponent<PositionComponent>(1920 / 1.75, 1080 / 1.75, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Esc / Controller's Home button:", 35, RAY::Vector2(), BLACK);
auto &back = scene->addEntity("back to 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::LobbyScene;
})
.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;
}
}
+1 -1
View File
@@ -90,7 +90,7 @@ namespace BBM
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_htp.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
gameState.nextScene = BBM::GameState::SceneID::HowToPlayScene;
})
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
+1
View File
@@ -120,6 +120,7 @@ namespace BBM
gameState._loadedScenes[GameState::SceneID::CreditScene] = loadCreditScene();
gameState._loadedScenes[GameState::SceneID::SplashScreen] = loadSplashScreenScene();
gameState._loadedScenes[GameState::SceneID::LobbyScene] = loadLobbyScene();
gameState._loadedScenes[GameState::SceneID::HowToPlayScene] = loadHowToPlayScene();
}
int Runner::run()
+3
View File
@@ -59,6 +59,9 @@ namespace BBM
//! @brief load all data related to splash screen
static std::shared_ptr<WAL::Scene> loadSplashScreenScene();
//! @brief load how to play screen
static std::shared_ptr<WAL::Scene> loadHowToPlayScene();
//! @brief loads all scenes in the game state
static void loadScenes();
};