MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
mutatris::GameGrid Class Reference

#include <examples/mutatris/game_grid.hpp>

Public Member Functions

Blockat (int x, int y)
const Blockat (int x, int y) const
bool canMoveDown () const
 GameGrid ()
int height () const
void initGrid (int width, int height)
int width () const

Public Attributes

Piece gamePiece

Detailed Description

Definition at line 11 of file game_grid.hpp.

Constructor & Destructor Documentation

◆ GameGrid()

mutatris::GameGrid::GameGrid ( )

Definition at line 7 of file game_grid.cpp.

8 : gamePiece(this) {
9 }

Member Function Documentation

◆ at() [1/2]

Block * mutatris::GameGrid::at ( int x,
int y )
nodiscard

Definition at line 18 of file game_grid.cpp.

18 {
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 }

◆ at() [2/2]

const Block * mutatris::GameGrid::at ( int x,
int y ) const
nodiscard

Definition at line 25 of file game_grid.cpp.

25 {
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 }

◆ canMoveDown()

bool mutatris::GameGrid::canMoveDown ( ) const
nodiscard

Definition at line 32 of file game_grid.cpp.

32 {
33 return gamePiece.getDirection() == 3 || gamePiece.checkLocation(gamePiece.getX(), gamePiece.getY()) || gamePiece.getY() != 0;
34 }

◆ height()

int mutatris::GameGrid::height ( ) const
inlinenodiscard

Definition at line 19 of file game_grid.hpp.

19{ return gridHeight; }

◆ initGrid()

void mutatris::GameGrid::initGrid ( int width,
int height )

Definition at line 11 of file game_grid.cpp.

11 {
12 gridWidth = width;
13 gridHeight = height;
14 cells.assign(static_cast<std::size_t>(width * height), {});
15 gamePiece.reset();
16 }
int width() const
Definition game_grid.hpp:18
int height() const
Definition game_grid.hpp:19

◆ width()

int mutatris::GameGrid::width ( ) const
inlinenodiscard

Definition at line 18 of file game_grid.hpp.

18{ return gridWidth; }

Member Data Documentation

◆ gamePiece

Piece mutatris::GameGrid::gamePiece

Definition at line 22 of file game_grid.hpp.


The documentation for this class was generated from the following files: