MXVK Vulkan Framework 0.33.1
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
game_grid.cpp
Go to the documentation of this file.
1#include "game_grid.hpp"
2
3#include <cstddef>
4
5namespace mutatris {
6
8 : gamePiece(this) {
9 }
10
12 gridWidth = width;
13 gridHeight = height;
14 cells.assign(static_cast<std::size_t>(width * height), {});
16 }
17
18 Block *GameGrid::at(int x, int y) {
19 if (x < 0 || x >= gridWidth || y < 0 || y >= gridHeight) {
20 return nullptr;
21 }
22 return &cells[static_cast<std::size_t>(y * gridWidth + x)];
23 }
24
25 const Block *GameGrid::at(int x, int y) const {
26 if (x < 0 || x >= gridWidth || y < 0 || y >= gridHeight) {
27 return nullptr;
28 }
29 return &cells[static_cast<std::size_t>(y * gridWidth + x)];
30 }
31
35
36} // namespace mutatris
int width() const
Definition game_grid.hpp:18
bool canMoveDown() const
Definition game_grid.cpp:32
void initGrid(int width, int height)
Definition game_grid.cpp:11
int height() const
Definition game_grid.hpp:19
Block * at(int x, int y)
Definition game_grid.cpp:18
int getY() const
Definition piece.hpp:28
bool checkLocation(int next_x, int next_y) const
Definition piece.cpp:33
int getX() const
Definition piece.hpp:27
int getDirection() const
Definition piece.hpp:29
void reset()
Definition piece.cpp:15