diff --git a/include/game/Constants.hpp b/include/game/Constants.hpp index f608ea6..f84acca 100644 --- a/include/game/Constants.hpp +++ b/include/game/Constants.hpp @@ -104,7 +104,7 @@ namespace COLOURS { } namespace TIMINGS { - + const float INTRO_OPEN_TIME = 4.0f; } namespace TRANSITIONS { @@ -152,4 +152,4 @@ namespace BUTTONS { namespace GAME { -} \ No newline at end of file +} diff --git a/include/game/MenuStages.hpp b/include/game/MenuStages.hpp index 761549d..8c7e7c1 100644 --- a/include/game/MenuStages.hpp +++ b/include/game/MenuStages.hpp @@ -1,11 +1,25 @@ #pragma once #include "BaseStage.hpp" +#include "Font.hpp" +#include "Timer.hpp" #include "Constants.hpp" #include "GameStages.hpp" +class IntroStage : public Framework::BaseStage { +public: + void start(); + + bool update(float dt); + void render(); + +private: + Framework::Timer intro_timer; + Framework::Text intro_text; +}; + class TitleStage : public Framework::BaseStage { public: void start(); diff --git a/src/game/Game.cpp b/src/game/Game.cpp index 485ab12..7553728 100644 --- a/src/game/Game.cpp +++ b/src/game/Game.cpp @@ -5,7 +5,7 @@ Game::Game() : BaseGame() { } void Game::start() { - stage = new TitleStage(); + stage = new IntroStage(); } void Game::end() { @@ -64,4 +64,4 @@ void Game::clear_data() { // Don't need to clear up graphics objects items - it's done for us in BaseGame // Clear up anything else we need to -} \ No newline at end of file +} diff --git a/src/game/MenuStages.cpp b/src/game/MenuStages.cpp index d202e47..a064183 100644 --- a/src/game/MenuStages.cpp +++ b/src/game/MenuStages.cpp @@ -1,5 +1,49 @@ #include "MenuStages.hpp" +// IntroStage + +void IntroStage::start() { + intro_text = Framework::Text(graphics_objects->font_ptrs[GRAPHICS_OBJECTS::FONTS::MAIN_FONT], "Some intro text", COLOURS::BLACK); + + intro_timer.stop(); + + // Start transition + set_transition(graphics_objects->transition_ptrs[GRAPHICS_OBJECTS::TRANSITIONS::FADE_TRANSITION]); + transition->open(); +} + +bool IntroStage::update(float dt) { + transition->update(dt); + intro_timer.update(dt); + + if (transition->is_open()) { + if (intro_timer.running()) { + if (intro_timer.time() >= TIMINGS::INTRO_OPEN_TIME) { + transition->close(); + } + } + else { + intro_timer.reset(); + intro_timer.start(); + } + } + else if (transition->is_closed()) { + // Finish intro + finish(new TitleStage()); + } + + return true; +} + +void IntroStage::render() { + graphics_objects->graphics_ptr->fill(COLOURS::BLUE); + + // Display some intro text in the centre of the display + intro_text.render(WINDOW::SIZE_HALF); + + transition->render(); +} + // TitleStage void TitleStage::start() {