diff options
Diffstat (limited to 'src/games/Game.cpp')
| -rw-r--r-- | src/games/Game.cpp | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/src/games/Game.cpp b/src/games/Game.cpp index 7ed94eb..0520a36 100644 --- a/src/games/Game.cpp +++ b/src/games/Game.cpp @@ -2,7 +2,6 @@ #include <games/tetris/Tetris.hpp> #include <games/snake/Snake.hpp> #include <games/minesweeper/Minesweeper.hpp> -#include <games/breakout/Breakout.hpp> #include <assert.h> #include <memory> @@ -16,20 +15,16 @@ Game::Select(GameType type) return nullptr; } break; - case tetris: { - return std::make_unique<Tetris>(); + case minesweeper: { + return std::make_unique<Minesweeper>(); } break; case snake: { return std::make_unique<Snake>(); } break; - case minesweeper: { - return std::make_unique<Minesweeper>(); - } break; - - case breakout: { - return std::make_unique<Breakout>(); + case tetris: { + return std::make_unique<Tetris>(); } break; InvalidDefaultCase; @@ -38,3 +33,49 @@ Game::Select(GameType type) return nullptr; } +float +Game::ProcessDt() +{ + uint64_t tnow_milliseconds = SDL_GetTicks(); + uint64_t tlast_milliseconds = m_tlast_milliseconds; + uint64_t dt_milliseconds = tnow_milliseconds - tlast_milliseconds; + + float dt_seconds = float(dt_milliseconds) / 1000.0f; + dt_seconds += m_dt_remaining_seconds; + + m_tlast_milliseconds = tnow_milliseconds; + m_dt_remaining_seconds = 0.0f; + + return dt_seconds; +} + +void +Game::DrawGameOverMenu() +{ + ImGui::Begin("DefaultGameOverMenu"); + ImGui::Text("Game Over."); + if (ImGui::Button("Play Again")) { + m_game_status = game_starting; + } + if (ImGui::Button("Exit")) { + m_game_status = game_exit; + } + ImGui::End(); +} + +void +Game::DrawGamePausedMenu() +{ + ImGui::Begin("DefaultGamePauseMenu"); + if (ImGui::Button("Resume")) { + m_game_status = game_resuming; + } + if (ImGui::Button("Restart")) { + m_game_status = game_starting; + } + if (ImGui::Button("Exit")) { + m_game_status = game_exit; + } + ImGui::End(); +} + |
