From ce8ce3b4a9095cf7242dc45aaf3657a44d4d3276 Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Mon, 14 Jun 2021 10:26:08 +0200 Subject: [PATCH] split runner file: splash, title + credit --- CMakeLists.txt | 3 + sources/Runner/CreditScene.cpp | 73 +++++++++++++++++++ sources/Runner/Runner.cpp | 103 --------------------------- sources/Runner/SplashScreenScene.cpp | 37 ++++++++++ sources/Runner/TitleScreenScene.cpp | 47 ++++++++++++ 5 files changed, 160 insertions(+), 103 deletions(-) create mode 100644 sources/Runner/CreditScene.cpp create mode 100644 sources/Runner/SplashScreenScene.cpp create mode 100644 sources/Runner/TitleScreenScene.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b4aa8778..072f19b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,9 @@ set(SOURCES sources/Component/IntroAnimation/IntroAnimationComponent.cpp sources/System/IntroAnimation/IntroAnimationSystem.hpp sources/System/IntroAnimation/IntroAnimationSystem.cpp + sources/Runner/SplashScreenScene.cpp + sources/Runner/TitleScreenScene.cpp + sources/Runner/CreditScene.cpp ) add_executable(bomberman sources/main.cpp diff --git a/sources/Runner/CreditScene.cpp b/sources/Runner/CreditScene.cpp new file mode 100644 index 00000000..38c9b77e --- /dev/null +++ b/sources/Runner/CreditScene.cpp @@ -0,0 +1,73 @@ + +#include +#include +#include "Runner.hpp" +#include +#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 Runner::loadCreditScene() + { + auto scene = std::make_shared(); + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + + scene->addEntity("Control entity") + .addComponent() + .addComponent() + .addComponent("assets/musics/music_title.ogg") + .addComponent(sounds); + + auto &raylibLogo = scene->addEntity("raylib logo") + .addComponent(1920 / 4, 1080 / 1.75, 0) + .addComponent("assets/raylib.png"); + auto &raylibText = scene->addEntity("raylib text") + .addComponent(1920 / 4, 1080 / 2, 0) + .addComponent("Powered by:", 35, RAY::Vector2(), BLACK); + auto &otherRepoText = scene->addEntity("other repo text") + .addComponent(1920 / 4, 1080 / 4, 0) + .addComponent("Many Thanks to:", 35, RAY::Vector2(), BLACK); + auto &BriansRepo = scene->addEntity("thx brian") + .addComponent(1920 / 3.5, 1080 / 3.5, 0) + .addComponent("Brian Guitteny (and his team)", 35, RAY::Vector2(), BLACK); + auto &team = scene->addEntity("team") + .addComponent(1920 / 1.5, 1080 / 3.5, 0) + .addComponent("Team:\n Zoe Roux\n Clément Le Bihan\n Arthur Jamet\n Louis Auzuret\n Benjamin Henry\n Tom Augier", 35, RAY::Vector2(), BLACK); + auto &back = scene->addEntity("back to 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 diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index d9410f21..364f90e4 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -108,35 +108,6 @@ namespace BBM .addSystem(window); } - std::shared_ptr Runner::loadTitleScreenScene() - { - static const std::map sounds = { - {SoundComponent::JUMP, "assets/sounds/click.ogg"} - }; - auto scene = std::make_shared(); - scene->addEntity("control") - .addComponent() - .addComponent() - .addComponent(sounds) - .addComponent("assets/musics/music_title.ogg"); - scene->addEntity("background") - .addComponent() - .addComponent("assets/plain_menu_background.png"); - scene->addEntity("logo") - .addComponent(320, 180, 0) - .addComponent("assets/logo_big.png"); - scene->addEntity("text_prompt") - .addComponent(1920 / 2.5, 1080 - 130, 0) - .addComponent("Press space", 70, RAY::Vector2(), BLACK) - .addComponent() - .addComponent() - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; - }); - return scene; - } - std::shared_ptr Runner::loadMainMenuScene() { static const std::map sounds = { @@ -554,80 +525,6 @@ namespace BBM return scene; } - std::shared_ptr Runner::loadCreditScene() - { - auto scene = std::make_shared(); - static const std::map sounds = { - {SoundComponent::JUMP, "assets/sounds/click.ogg"} - }; - - scene->addEntity("background") - .addComponent() - .addComponent("assets/plain_menu_background.png"); - - scene->addEntity("Control entity") - .addComponent() - .addComponent() - .addComponent("assets/musics/music_title.ogg") - .addComponent(sounds); - - auto &raylibLogo = scene->addEntity("raylib logo") - .addComponent(1920 / 4, 1080 / 1.75, 0) - .addComponent("assets/raylib.png"); - auto &raylibText = scene->addEntity("raylib text") - .addComponent(1920 / 4, 1080 / 2, 0) - .addComponent("Powered by:", 35, RAY::Vector2(), BLACK); - auto &otherRepoText = scene->addEntity("other repo text") - .addComponent(1920 / 4, 1080 / 4, 0) - .addComponent("Many Thanks to:", 35, RAY::Vector2(), BLACK); - auto &BriansRepo = scene->addEntity("thx brian") - .addComponent(1920 / 3.5, 1080 / 3.5, 0) - .addComponent("Brian Guitteny (and his team)", 35, RAY::Vector2(), BLACK); - auto &team = scene->addEntity("team") - .addComponent(1920 / 1.5, 1080 / 3.5, 0) - .addComponent("Team:\n Zoe Roux\n Clément Le Bihan\n Arthur Jamet\n Louis Auzuret\n Benjamin Henry\n Tom Augier", 35, RAY::Vector2(), BLACK); - auto &back = scene->addEntity("back to 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; - } - - std::shared_ptr Runner::loadSplashScreenScene() - { - auto scene = std::make_shared(); - - auto &splashComponent = scene->addEntity("animation component") - .addComponent() - .addComponent() - .addComponent(); - auto &background = scene->addEntity("background") - .addComponent(0, 0, 0) - .addComponent(RAY::Vector2(), RAY::Vector2(1920, 1080)); - auto &text = scene->addEntity("powered by text") - .addComponent(1920 / 2 - 200, 1080 / 2 - 180, 0) - .addComponent("powered by", 30, RAY::Vector2(), BLACK); - auto &skipText = scene->addEntity("Press space to skip") - .addComponent(1920 - 250, 1080 - 30, 0) - .addComponent("Press space to skip", 20, RAY::Vector2(), BLACK); - return scene; - } - void Runner::loadScenes() { gameState._loadedScenes[GameState::SceneID::MainMenuScene] = loadMainMenuScene(); diff --git a/sources/Runner/SplashScreenScene.cpp b/sources/Runner/SplashScreenScene.cpp new file mode 100644 index 00000000..455a0e95 --- /dev/null +++ b/sources/Runner/SplashScreenScene.cpp @@ -0,0 +1,37 @@ + +#include +#include +#include "Runner.hpp" +#include "Component/Music/MusicComponent.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" +#include "Component/IntroAnimation/IntroAnimationComponent.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadSplashScreenScene() + { + auto scene = std::make_shared(); + + auto &splashComponent = scene->addEntity("animation component") + .addComponent() + .addComponent() + .addComponent(); + auto &background = scene->addEntity("background") + .addComponent(0, 0, 0) + .addComponent(RAY::Vector2(), RAY::Vector2(1920, 1080)); + auto &text = scene->addEntity("powered by text") + .addComponent(1920 / 2 - 200, 1080 / 2 - 180, 0) + .addComponent("powered by", 30, RAY::Vector2(), BLACK); + auto &skipText = scene->addEntity("Press space to skip") + .addComponent(1920 - 250, 1080 - 30, 0) + .addComponent("Press space to skip", 20, RAY::Vector2(), BLACK); + return scene; + } +} \ No newline at end of file diff --git a/sources/Runner/TitleScreenScene.cpp b/sources/Runner/TitleScreenScene.cpp new file mode 100644 index 00000000..0cbbf488 --- /dev/null +++ b/sources/Runner/TitleScreenScene.cpp @@ -0,0 +1,47 @@ + +#include +#include +#include "Runner.hpp" +#include +#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 Runner::loadTitleScreenScene() + { + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + auto scene = std::make_shared(); + scene->addEntity("control") + .addComponent() + .addComponent() + .addComponent(sounds) + .addComponent("assets/musics/music_title.ogg"); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("logo") + .addComponent(320, 180, 0) + .addComponent("assets/logo_big.png"); + scene->addEntity("text_prompt") + .addComponent(1920 / 2.5, 1080 - 130, 0) + .addComponent("Press space", 70, RAY::Vector2(), BLACK) + .addComponent() + .addComponent() + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; + }); + return scene; + } +} \ No newline at end of file