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{puzzle_drop.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 {}
int position = 0

Detailed Description

Definition at line 69 of file puzzle_drop.cpp.

Member Function Documentation

◆ move_down()

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

Definition at line 105 of file puzzle_drop.cpp.

105 {
106 for (Block &block : blocks) {
107 ++block.y;
108 }
109 }

◆ move_left()

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

Definition at line 93 of file puzzle_drop.cpp.

93 {
94 for (Block &block : blocks) {
95 --block.x;
96 }
97 }

◆ move_right()

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

Definition at line 99 of file puzzle_drop.cpp.

99 {
100 for (Block &block : blocks) {
101 ++block.x;
102 }
103 }

◆ new_piece()

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

Definition at line 73 of file puzzle_drop.cpp.

73 {
74 blocks[0] = {start_x, start_y, random_type(rng)};
75 blocks[1] = {start_x, start_y + 1, random_type(rng)};
76 blocks[2] = {start_x, start_y + 2, random_type(rng)};
77 position = 0;
78 }

◆ rotate_left()

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

Definition at line 111 of file puzzle_drop.cpp.

111 {
112 if (position == 0) {
113 blocks[1].y -= 1;
114 blocks[1].x -= 1;
115 blocks[2].x -= 2;
116 blocks[2].y -= 2;
117 position = 1;
118 } else if (position == 1) {
119 blocks[1].y += 1;
120 blocks[1].x += 1;
121 blocks[2].y += 2;
122 blocks[2].x += 2;
123 position = 0;
124 }
125 }

◆ rotate_right()

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

Definition at line 127 of file puzzle_drop.cpp.

127 {
128 if (position == 0) {
129 blocks[1].x += 1;
130 blocks[1].y -= 1;
131 blocks[2].x += 2;
132 blocks[2].y -= 2;
133 position = 2;
134 } else if (position == 2) {
135 blocks[1].x -= 1;
136 blocks[1].y += 1;
137 blocks[2].x -= 2;
138 blocks[2].y += 2;
139 position = 0;
140 }
141 }

◆ shift()

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

Definition at line 80 of file puzzle_drop.cpp.

80 {
81 const std::array<BlockType, 3> types{blocks[0].type, blocks[1].type, blocks[2].type};
82 if (direction == ShiftDirection::Down) {
83 blocks[0].type = types[2];
84 blocks[1].type = types[0];
85 blocks[2].type = types[1];
86 } else {
87 blocks[0].type = types[1];
88 blocks[1].type = types[2];
89 blocks[2].type = types[0];
90 }
91 }

Member Data Documentation

◆ blocks

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

Definition at line 70 of file puzzle_drop.cpp.

70{};

◆ position

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

Definition at line 71 of file puzzle_drop.cpp.


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