From 606d028dac5118329e7561af33b15988db84465f Mon Sep 17 00:00:00 2001 From: fschildt Date: Mon, 6 Oct 2025 09:25:04 +0200 Subject: make everything prettier --- src/games/Game.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 9 deletions(-) (limited to 'src/games/Game.cpp') 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 #include #include -#include #include #include @@ -16,20 +15,16 @@ Game::Select(GameType type) return nullptr; } break; - case tetris: { - return std::make_unique(); + case minesweeper: { + return std::make_unique(); } break; case snake: { return std::make_unique(); } break; - case minesweeper: { - return std::make_unique(); - } break; - - case breakout: { - return std::make_unique(); + case tetris: { + return std::make_unique(); } 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(); +} + -- cgit v1.2.3