diff options
| author | fschildt <florian.schildt@protonmail.com> | 2025-09-27 12:40:31 +0200 | 
|---|---|---|
| committer | fschildt <florian.schildt@protonmail.com> | 2025-09-27 12:40:31 +0200 | 
| commit | dbb42e741d29ab213f2a51fc8d9568c02f844647 (patch) | |
| tree | 8f8e59c70b79082b0ee1410d8a891462e6a0f915 /src/games/minesweeper | |
| parent | f28e9c3e03a9f94764b3811f7c4aa01991943fc7 (diff) | |
add font glyph drawing
Diffstat (limited to 'src/games/minesweeper')
| -rw-r--r-- | src/games/minesweeper/Minesweeper.cpp | 13 | ||||
| -rw-r--r-- | src/games/minesweeper/Minesweeper.hpp | 9 | 
2 files changed, 21 insertions, 1 deletions
diff --git a/src/games/minesweeper/Minesweeper.cpp b/src/games/minesweeper/Minesweeper.cpp index 6dc77a4..abb9515 100644 --- a/src/games/minesweeper/Minesweeper.cpp +++ b/src/games/minesweeper/Minesweeper.cpp @@ -25,8 +25,11 @@ Minesweeper::Minesweeper()      m_CellOuterViewSize = {cell_size, cell_size};      m_CellInnerViewSize = {cell_size_without_border, cell_size_without_border}; +    m_Font.Init("fonts/dejavu_ttf/DejaVuSansMono.ttf", 32); +    for (uint32_t i = 0; i < m_DigitGlyphs.size(); ++i) { +        m_Font.LoadGlyph(m_DigitGlyphs[i], i + '0'); +    } -    // Todo: assert various stuff      Reinit();  } @@ -278,6 +281,14 @@ void Minesweeper::DrawBoard(RenderGroup &render_group) {      }; +    // Temporary: Drawing Glyph Test +    render_group.PushBitmap( +            {100.0f, 100.0f, 10.0f}, +            m_DigitGlyphs[1].bitmap.width, +            m_DigitGlyphs[1].bitmap.height, +            m_DigitGlyphs[1].bitmap.pixels.get()); + +      for (int32_t y = 0; y < m_MapHeight; y++) {          for (int32_t x = 0; x < m_MapWidth; x++) {              V2F32 world_pos = { diff --git a/src/games/minesweeper/Minesweeper.hpp b/src/games/minesweeper/Minesweeper.hpp index 4906464..b081806 100644 --- a/src/games/minesweeper/Minesweeper.hpp +++ b/src/games/minesweeper/Minesweeper.hpp @@ -1,6 +1,10 @@  #pragma once  #include <games/Game.hpp> +#include <common/Font.hpp> + +#include <array> +  namespace std {      template <> @@ -13,6 +17,7 @@ namespace std {      };  } +  enum class MinesweeperRunState {      Resume,      Pause, @@ -21,6 +26,7 @@ enum class MinesweeperRunState {      Exit  }; +  class Minesweeper : public Game {      public:          Minesweeper(); @@ -76,6 +82,9 @@ class Minesweeper : public Game {          uint32_t m_IsFlaggedBitmap[MAX_MAP_HEIGHT] {};          uint32_t m_IsMineBitmap[MAX_MAP_HEIGHT] {};          int32_t m_AdjacentMineCounters[MAX_MAP_WIDTH * MAX_MAP_HEIGHT] {}; + +        Font m_Font; +        std::array<Glyph, 9> m_DigitGlyphs;  };  | 
