MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
puzzle_game.hpp
Go to the documentation of this file.
1#ifndef MUTATRIS_PUZZLE_GAME_HPP
2#define MUTATRIS_PUZZLE_GAME_HPP
3
4#include <array>
5#include <functional>
6
7#include "game_grid.hpp"
8
9namespace mutatris {
10
11 class PuzzleGame {
12 public:
13 explicit PuzzleGame(int difficulty, std::function<void()> lineSoundCallback);
14
15 void newGame(int difficulty);
16 void procBlocks();
17
18 std::array<GameGrid, 4> grid{};
19 int score = 0;
20 unsigned int timeout = 1200;
21 int clears = 0;
22 int level = 0;
23
24 private:
25 struct CellRef {
26 int gridIndex = 0;
27 int x = 0;
28 int y = 0;
29 };
30
31 struct CellBounds {
32 int x = 0;
33 int y = 0;
34 int width = 0;
35 int height = 0;
36 };
37
38 [[nodiscard]] Block *blockAt(const CellRef &cell);
39 [[nodiscard]] const Block *blockAt(const CellRef &cell) const;
40 [[nodiscard]] static CellBounds cellBounds(const CellRef &cell);
41 [[nodiscard]] bool sameCell(const CellRef &a, const CellRef &b) const;
42 [[nodiscard]] bool findNextVisualMatch(const CellRef &current, int color, int dx, int dy, CellRef &next) const;
43 [[nodiscard]] bool clearVisualRun();
44 bool clearRun(GameGrid &focusGrid, int x, int y, int dx, int dy);
45 void clearTopBottomSeams();
46 bool clearSeam(std::array<Block *, 4> blocks);
47 void moveDownBlocks();
48 static void markClearing(Block &block);
49 void recordClear();
50 void playClearSound();
51
52 std::function<void()> playLineSound;
53 };
54
55} // namespace mutatris
56
57#endif
PuzzleGame(int difficulty, std::function< void()> lineSoundCallback)
void newGame(int difficulty)
std::array< GameGrid, 4 > grid