MXVK Vulkan Framework 0.35.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_height > colors {}
std::array< int, piece_height > next_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 125 of file main.cpp.

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

◆ move_left()

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

Definition at line 113 of file main.cpp.

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

◆ move_right()

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

Definition at line 119 of file main.cpp.

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

◆ new_piece()

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

Definition at line 93 of file main.cpp.

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

◆ rotate_left()

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

Definition at line 131 of file main.cpp.

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

◆ rotate_right()

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

Definition at line 147 of file main.cpp.

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

◆ shift()

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

Definition at line 100 of file main.cpp.

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

Member Data Documentation

◆ blocks

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

Definition at line 90 of file main.cpp.

◆ colors

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

Definition at line 81 of file main.cpp.

◆ next_colors

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

Definition at line 82 of file main.cpp.

◆ position

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

Definition at line 91 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: