MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
anonymous_namespace{main.cpp}::Piece Struct Reference

Public Member Functions

void move_down ()
void move_left ()
void move_right ()
void new_piece (int start_x, int start_y, std::mt19937 &rng)
void rotate_left ()
void rotate_right ()
void shift (ShiftDirection direction)

Public Attributes

std::array< Block, 3 > blocks {}
std::array< int, piece_heightcolors {}
std::array< int, piece_heightnext_colors {}
int position = 0
int x = 3
int y = 0

Detailed Description

Definition at line 78 of file main.cpp.

Member Function Documentation

◆ move_down()

void anonymous_namespace{main.cpp}::Piece::move_down ( )
inline

Definition at line 127 of file main.cpp.

127 {
128 for (Block &block : blocks) {
129 ++block.y;
130 }
131 }
std::array< Block, 3 > blocks
Definition main.cpp:92

◆ move_left()

void anonymous_namespace{main.cpp}::Piece::move_left ( )
inline

Definition at line 115 of file main.cpp.

115 {
116 for (Block &block : blocks) {
117 --block.x;
118 }
119 }

◆ move_right()

void anonymous_namespace{main.cpp}::Piece::move_right ( )
inline

Definition at line 121 of file main.cpp.

121 {
122 for (Block &block : blocks) {
123 ++block.x;
124 }
125 }

◆ new_piece()

void anonymous_namespace{main.cpp}::Piece::new_piece ( int start_x,
int start_y,
std::mt19937 & rng )
inline

Definition at line 95 of file main.cpp.

95 {
96 blocks[0] = {start_x, start_y, random_type(rng)};
97 blocks[1] = {start_x, start_y + 1, random_type(rng)};
98 blocks[2] = {start_x, start_y + 2, random_type(rng)};
99 position = 0;
100 }

◆ rotate_left()

void anonymous_namespace{main.cpp}::Piece::rotate_left ( )
inline

Definition at line 133 of file main.cpp.

133 {
134 if (position == 0) {
135 blocks[1].y -= 1;
136 blocks[1].x -= 1;
137 blocks[2].x -= 2;
138 blocks[2].y -= 2;
139 position = 1;
140 } else if (position == 1) {
141 blocks[1].y += 1;
142 blocks[1].x += 1;
143 blocks[2].y += 2;
144 blocks[2].x += 2;
145 position = 0;
146 }
147 }

◆ rotate_right()

void anonymous_namespace{main.cpp}::Piece::rotate_right ( )
inline

Definition at line 149 of file main.cpp.

149 {
150 if (position == 0) {
151 blocks[1].x += 1;
152 blocks[1].y -= 1;
153 blocks[2].x += 2;
154 blocks[2].y -= 2;
155 position = 2;
156 } else if (position == 2) {
157 blocks[1].x -= 1;
158 blocks[1].y += 1;
159 blocks[2].x -= 2;
160 blocks[2].y += 2;
161 position = 0;
162 }
163 }

◆ shift()

void anonymous_namespace{main.cpp}::Piece::shift ( ShiftDirection direction)
inline

Definition at line 102 of file main.cpp.

102 {
103 const std::array<BlockType, 3> types{blocks[0].type, blocks[1].type, blocks[2].type};
104 if (direction == ShiftDirection::Down) {
105 blocks[0].type = types[2];
106 blocks[1].type = types[0];
107 blocks[2].type = types[1];
108 } else {
109 blocks[0].type = types[1];
110 blocks[1].type = types[2];
111 blocks[2].type = types[0];
112 }
113 }

Member Data Documentation

◆ blocks

std::array<Block, 3> anonymous_namespace{main.cpp}::Piece::blocks {}

Definition at line 92 of file main.cpp.

92{};

◆ colors

std::array< int, piece_height > anonymous_namespace{main.cpp}::Piece::colors {}

Definition at line 81 of file main.cpp.

81{};

◆ next_colors

std::array< int, piece_height > anonymous_namespace{main.cpp}::Piece::next_colors {}

Definition at line 82 of file main.cpp.

82{};

◆ position

int anonymous_namespace{main.cpp}::Piece::position = 0

Definition at line 93 of file main.cpp.

◆ x

int anonymous_namespace{main.cpp}::Piece::x = 3

Definition at line 79 of file main.cpp.

◆ y

int anonymous_namespace{main.cpp}::Piece::y = 0

Definition at line 80 of file main.cpp.


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