summary refs log tree commit diff stats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 10 insertions, 5 deletions
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 @@
1#include <vector> 1#include <vector>
2#include <fov.h> 2#include <fov.h>
3#include <iostream> 3#include <iostream>
4#include <memory>
4#include "util.h" 5#include "util.h"
5#include "game.h" 6#include "game.h"
6#include "renderer.h" 7#include "renderer.h"
@@ -21,7 +22,7 @@ int main(int, char**)
21 Renderer renderer; 22 Renderer renderer;
22 Muxer muxer; 23 Muxer muxer;
23 24
24 Game game(rng, muxer, renderer); 25 std::unique_ptr<Game> game = std::make_unique<Game>(rng, muxer, renderer);
25 26
26 constexpr int titleFadeLen = 2000; 27 constexpr int titleFadeLen = 2000;
27 bool doneTitles = false; 28 bool doneTitles = false;
@@ -32,22 +33,26 @@ int main(int, char**)
32 titleFade.start(titleFadeLen); 33 titleFade.start(titleFadeLen);
33 34
34 size_t lastTime = SDL_GetTicks(); 35 size_t lastTime = SDL_GetTicks();
35 while (!game.quit) 36 while (!game->quit)
36 { 37 {
37 size_t currentTime = SDL_GetTicks(); 38 size_t currentTime = SDL_GetTicks();
38 size_t frameTime = currentTime - lastTime; 39 size_t frameTime = currentTime - lastTime;
39 lastTime = currentTime; 40 lastTime = currentTime;
40 41
41 if (doneTitles) { 42 if (doneTitles) {
42 game.update(frameTime); 43 game->update(frameTime);
43 renderer.renderGame(game, true); 44 renderer.renderGame(*game, true);
44 muxer.update(); 45 muxer.update();
46
47 if (game->losing == LoseState::Done) {
48 game = std::make_unique<Game>(rng, muxer, renderer);
49 }
45 } else { 50 } else {
46 SDL_Event e; 51 SDL_Event e;
47 52
48 while (SDL_PollEvent(&e)) { 53 while (SDL_PollEvent(&e)) {
49 if (e.type == SDL_QUIT) { 54 if (e.type == SDL_QUIT) {
50 game.quit = true; 55 game->quit = true;
51 } 56 }
52 } 57 }
53 58