diff --git a/assets/sounds/splash_sound.ogg b/assets/sounds/splash_sound.ogg new file mode 100644 index 00000000..d9092e53 Binary files /dev/null and b/assets/sounds/splash_sound.ogg differ diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 80f057cc..d9410f21 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -60,11 +60,14 @@ namespace BBM { if (RAY::Window::getInstance().shouldClose()) engine.shouldClose = true; - if (gameState.currentScene == GameState::SceneID::GameScene) { + if (gameState.currentScene == GameState::SceneID::GameScene || gameState.currentScene == GameState::SceneID::SplashScreen) { for (auto &[_, component]: engine.getScene()->view()) { - if (component.pause) { + if (component.pause && gameState.currentScene == GameState::SceneID::GameScene) { gameState.nextScene = GameState::SceneID::PauseMenuScene; break; + } else if (gameState.currentScene == GameState::SceneID::SplashScreen && component.jump) { + gameState.nextScene = GameState::SceneID::TitleScreenScene; + break; } } } @@ -609,12 +612,19 @@ namespace BBM { auto scene = std::make_shared(); - auto &splashComponent = scene->addEntity("animation component") - .addComponent(); + .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; } diff --git a/sources/System/IntroAnimation/IntroAnimationSystem.cpp b/sources/System/IntroAnimation/IntroAnimationSystem.cpp index 10243eae..c5671987 100644 --- a/sources/System/IntroAnimation/IntroAnimationSystem.cpp +++ b/sources/System/IntroAnimation/IntroAnimationSystem.cpp @@ -4,7 +4,11 @@ #include "System/IntroAnimation/IntroAnimationSystem.hpp" #include "Entity/Entity.hpp" #include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" #include +#include +#include "Runner/Runner.hpp" +#include "Component/Music/MusicComponent.hpp" namespace RAY2D = RAY::Drawables::Drawables2D; @@ -20,6 +24,10 @@ namespace BBM auto &component = entity.get(); auto scene = wal.getScene(); RAY2D::Rectangle *rectangle = nullptr; + RAY2D::Text *text = nullptr; + static auto &rayText = scene->addEntity("raylibtext Rectangle") + .addComponent(1920 / 2 - 44, 1080 / 2 + 48, 0) + .addComponent("", 50, RAY::Vector2(), BLACK); static auto &bottomRectangle = scene->addEntity("bottom Rectangle") .addComponent(1920 / 2 - 128, 1080 / 2 - 128, 0) .addComponent(logoPos, RAY::Vector2(16, 16), BLACK); @@ -32,6 +40,7 @@ namespace BBM static auto &topRectangle = scene->addEntity("top Rectangle") .addComponent(1920 / 2 - 128, 1080 / 2 - 128, 0) .addComponent(logoPos, RAY::Vector2(16, 16), BLACK); + static short letterCounter = 0; switch (component.currentStep) { @@ -40,7 +49,7 @@ namespace BBM topRectangle.getComponent().drawable->setColor(BLACK); else topRectangle.getComponent().drawable->setColor(WHITE); - if (component.frameCounter == 120) { + if (component.frameCounter == 60) { component.currentStep = IntroAnimationComponent::animationSteps::topLeftgrowing; component.frameCounter = -1; topRectangle.getComponent().drawable->setColor(BLACK); @@ -63,8 +72,24 @@ namespace BBM rectangle->incrementWidth(4); rectangle = dynamic_cast(rightRectangle.getComponent().drawable.get()); rectangle->incrementHeight(4); - if (rectangle->getHeight() == 256) + if (rectangle->getHeight() == 256) { component.currentStep = IntroAnimationComponent::animationSteps::lettersTyping; + component.frameCounter = 0; + } + break; + case IntroAnimationComponent::animationSteps::lettersTyping: + if ((component.frameCounter / 15) % 2) { + letterCounter++; + text = dynamic_cast(rayText.getComponent().drawable.get()); + if (letterCounter == 2) { + scene->addEntity("startup sound") + .addComponent("assets/sounds/splash_sound.ogg") + .getComponent().playMusic(); + } + text->setText(std::string("raylib").substr(0, letterCounter)); + } + if (component.frameCounter == 60) + Runner::gameState.nextScene = Runner::gameState.TitleScreenScene; break; default: break;