From 935f1971bee684c6c9baded2564a550351cc5582 Mon Sep 17 00:00:00 2001 From: fschildt Date: Sat, 18 Oct 2025 11:33:30 +0200 Subject: minesweeper: add win/lose condition --- src/games/minesweeper/Minesweeper.hpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/games/minesweeper/Minesweeper.hpp') diff --git a/src/games/minesweeper/Minesweeper.hpp b/src/games/minesweeper/Minesweeper.hpp index fbdcb30..1db77ff 100644 --- a/src/games/minesweeper/Minesweeper.hpp +++ b/src/games/minesweeper/Minesweeper.hpp @@ -25,8 +25,9 @@ private: void ProcessEventDuringResume(SDL_Event& event); void Reset(Difficulty Difficulty); - void InitIsMineBitmap(int32_t mine_count); + void InitIsMineBitmap(); void InitAdjacentMineCounters(); + bool IsWon(); void UncoverMines(); void Uncover(int32_t x, int32_t y); @@ -43,28 +44,32 @@ private: private: void DrawBoard(); void DrawStartMenu(); + void DrawGameOverMenu(); private: - static constexpr int32_t max_map_height = 32; - static constexpr int32_t max_map_width = 32; + static constexpr int32_t s_max_grid_height = 32; + static constexpr int32_t s_max_grid_width = 32; private: Difficulty m_difficulty = beginner; + int32_t m_cells_uncovered; + int32_t m_mine_count; float m_world_width = 4.0f; float m_world_height = 3.0f; int32_t m_grid_width; - int32_t m_grid_height; V2F32 m_grid_pos; + int32_t m_grid_height; + V2F32 m_grid_pos; V2F32 m_cell_outer_size; V2F32 m_cell_inner_size; - uint32_t m_is_covered_bitmap[max_map_height] {}; - uint32_t m_is_flagged_bitmap[max_map_height] {}; - uint32_t m_is_mine_bitmap[max_map_height] {}; - int32_t m_adjacent_mine_counts[max_map_width * max_map_height] {}; + uint32_t m_is_covered_bitmap[s_max_grid_height] {}; + uint32_t m_is_flagged_bitmap[s_max_grid_height] {}; + uint32_t m_is_mine_bitmap[s_max_grid_height] {}; + int32_t m_adjacent_mine_counts[s_max_grid_width * s_max_grid_height] {}; Font m_font; }; -- cgit v1.2.3