From b2f0190f6b2a227a21dd4909476171f7cc371a2d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 19 Mar 2022 16:46:19 -0400 Subject: menu! --- src/main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 2bd8f3c..ae64079 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "util.h" #include "game.h" #include "renderer.h" @@ -21,7 +22,7 @@ int main(int, char**) Renderer renderer; Muxer muxer; - Game game(rng, muxer, renderer); + std::unique_ptr game = std::make_unique(rng, muxer, renderer); constexpr int titleFadeLen = 2000; bool doneTitles = false; @@ -32,22 +33,26 @@ int main(int, char**) titleFade.start(titleFadeLen); size_t lastTime = SDL_GetTicks(); - while (!game.quit) + while (!game->quit) { size_t currentTime = SDL_GetTicks(); size_t frameTime = currentTime - lastTime; lastTime = currentTime; if (doneTitles) { - game.update(frameTime); - renderer.renderGame(game, true); + game->update(frameTime); + renderer.renderGame(*game, true); muxer.update(); + + if (game->losing == LoseState::Done) { + game = std::make_unique(rng, muxer, renderer); + } } else { SDL_Event e; while (SDL_PollEvent(&e)) { if (e.type == SDL_QUIT) { - game.quit = true; + game->quit = true; } } -- cgit 1.4.1