diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-19 16:46:19 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-19 16:46:19 -0400 |
commit | b2f0190f6b2a227a21dd4909476171f7cc371a2d (patch) | |
tree | 0b12cdc515198a6daf5d0a39ed40f581e410cfba /src/main.cpp | |
parent | 81e8c1dae2e7e4be632d6e81d765b5dd43ea3927 (diff) | |
download | ether-b2f0190f6b2a227a21dd4909476171f7cc371a2d.tar.gz ether-b2f0190f6b2a227a21dd4909476171f7cc371a2d.tar.bz2 ether-b2f0190f6b2a227a21dd4909476171f7cc371a2d.zip |
menu!
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 15 |
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 | ||