From 3948b5f94cdaefe770d50197298f7fa5dd31e004 Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Tue, 8 Jun 2021 20:15:11 +0200 Subject: [PATCH] credit scene --- sources/Models/GameState.hpp | 1 + sources/Runner/Runner.cpp | 84 ++++++++++++++++++++++++++++++++---- sources/Runner/Runner.hpp | 3 ++ 3 files changed, 80 insertions(+), 8 deletions(-) diff --git a/sources/Models/GameState.hpp b/sources/Models/GameState.hpp index b9fc3e81..61f7f309 100644 --- a/sources/Models/GameState.hpp +++ b/sources/Models/GameState.hpp @@ -24,6 +24,7 @@ namespace BBM PauseMenuScene, LobbyScene, TitleScreenScene, + CreditScene, }; diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 1b3769d8..6f405f5d 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -191,10 +191,29 @@ namespace BBM { wal.shouldClose = true; }); - - play.getComponent().setButtonLinks(&exit, &settings); + auto &credits = scene->addEntity("credit button") + .addComponent(1920 - 100, 1080 - 30, 0) + .addComponent("Credits", 20, RAY::Vector2(), BLACK) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); + + text->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); + + text->setColor(ORANGE); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + gameState.nextScene = BBM::GameState::SceneID::CreditScene; + }); + play.getComponent().setButtonLinks(nullptr, &settings); settings.getComponent().setButtonLinks(&play, &exit); - exit.getComponent().setButtonLinks(&settings, &play); + exit.getComponent().setButtonLinks(&settings, &credits, nullptr, &credits); + credits.getComponent().setButtonLinks(&exit, nullptr, &exit); //needed material //music //sound @@ -274,9 +293,9 @@ namespace BBM //needed material //music //sound - play.getComponent().setButtonLinks(nullptr, nullptr, &exit, &settings); + play.getComponent().setButtonLinks(nullptr, nullptr, nullptr, &settings); settings.getComponent().setButtonLinks(nullptr, nullptr, &play, &exit); - exit.getComponent().setButtonLinks(nullptr, nullptr, &settings, &play); + exit.getComponent().setButtonLinks(nullptr, nullptr, &settings, nullptr); return scene; } @@ -436,14 +455,14 @@ namespace BBM //music //sound - music.getComponent().setButtonLinks(&back, &sound, &musicDown, &musicUp); + music.getComponent().setButtonLinks(nullptr, &sound, &musicDown, &musicUp); musicDown.getComponent().setButtonLinks(&debug, &sound, nullptr, &music); musicUp.getComponent().setButtonLinks(&debug, &sound, &music); sound.getComponent().setButtonLinks(&music, &debug, &soundDown, &soundUp); soundDown.getComponent().setButtonLinks(&music, &debug, nullptr, &sound); soundUp.getComponent().setButtonLinks(&music, &debug, &sound); - debug.getComponent().setButtonLinks(&sound, &back); - back.getComponent().setButtonLinks(&debug, &music); + debug.getComponent().setButtonLinks(&sound, &back, &back); + back.getComponent().setButtonLinks(&debug, nullptr, nullptr, &debug); return scene; } @@ -480,6 +499,54 @@ namespace BBM return scene; } + std::shared_ptr Runner::loadCreditScene() + { + auto scene = std::make_shared(); + + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("Control entity") + .addComponent() + .addComponent(); + + 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; + } + void Runner::loadScenes() { gameState._loadedScenes[GameState::SceneID::MainMenuScene] = loadMainMenuScene(); @@ -487,6 +554,7 @@ namespace BBM gameState._loadedScenes[GameState::SceneID::SettingsScene] = loadSettingsMenuScene(); gameState._loadedScenes[GameState::SceneID::PauseMenuScene] = loadPauseMenuScene(); gameState._loadedScenes[GameState::SceneID::TitleScreenScene] = loadTitleScreenScene(); + gameState._loadedScenes[GameState::SceneID::CreditScene] = loadCreditScene(); } int Runner::run() diff --git a/sources/Runner/Runner.hpp b/sources/Runner/Runner.hpp index 608dba0b..6c42adfe 100644 --- a/sources/Runner/Runner.hpp +++ b/sources/Runner/Runner.hpp @@ -43,6 +43,9 @@ namespace BBM //! @brief load all data related to game screen static std::shared_ptr loadGameScene(); + //! @brief load all data related to credit screen + static std::shared_ptr loadCreditScene(); + //! @brief loads all scenes in the game state static void loadScenes(); };