MXVK Vulkan Framework
0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
piece.hpp
Go to the documentation of this file.
1
#ifndef MUTATRIS_PIECE_HPP
2
#define MUTATRIS_PIECE_HPP
3
4
#include <array>
5
#include <cstddef>
6
7
#include "
common.hpp
"
8
9
namespace
mutatris
{
10
11
class
GameGrid
;
12
13
class
Piece
{
14
public
:
15
explicit
Piece
(
GameGrid
*owner);
16
17
void
reset
();
18
void
shiftColors
();
19
void
moveLeft
();
20
void
moveRight
();
21
[[nodiscard]]
bool
moveDown
();
22
[[nodiscard]]
bool
drop
();
23
void
shiftDirection
();
24
[[nodiscard]]
bool
setBlock
();
25
[[nodiscard]]
bool
checkLocation
(
int
next_x,
int
next_y)
const
;
26
27
[[nodiscard]]
int
getX
()
const
{
return
x; }
28
[[nodiscard]]
int
getY
()
const
{
return
y; }
29
[[nodiscard]]
int
getDirection
()
const
{
return
direction; }
30
[[nodiscard]]
const
Block
*
at
(
int
index)
const
{
31
return
index >= 0 && index < static_cast<int>(blocks.size()) ? &blocks[
static_cast<
std::size_t
>
(index)] :
nullptr
;
32
}
33
34
private
:
35
std::array<Block, 3> blocks{};
36
int
x = 0;
37
int
y = 0;
38
int
direction = 0;
39
GameGrid *grid =
nullptr
;
40
};
41
42
}
// namespace mutatris
43
44
#endif
mutatris::GameGrid
Definition
game_grid.hpp:11
mutatris::Piece::Piece
Piece(GameGrid *owner)
Definition
piece.cpp:11
mutatris::Piece::getY
int getY() const
Definition
piece.hpp:28
mutatris::Piece::drop
bool drop()
Definition
piece.cpp:78
mutatris::Piece::checkLocation
bool checkLocation(int next_x, int next_y) const
Definition
piece.cpp:33
mutatris::Piece::getX
int getX() const
Definition
piece.hpp:27
mutatris::Piece::setBlock
bool setBlock()
Definition
piece.cpp:93
mutatris::Piece::shiftDirection
void shiftDirection()
Definition
piece.cpp:85
mutatris::Piece::getDirection
int getDirection() const
Definition
piece.hpp:29
mutatris::Piece::moveDown
bool moveDown()
Definition
piece.cpp:69
mutatris::Piece::shiftColors
void shiftColors()
Definition
piece.cpp:26
mutatris::Piece::moveLeft
void moveLeft()
Definition
piece.cpp:57
mutatris::Piece::at
const Block * at(int index) const
Definition
piece.hpp:30
mutatris::Piece::moveRight
void moveRight()
Definition
piece.cpp:63
mutatris::Piece::reset
void reset()
Definition
piece.cpp:15
common.hpp
mutatris
Definition
common.hpp:6
mutatris::Block
Definition
common.hpp:43
examples
mutatris
piece.hpp
Generated by
1.16.1