Tetris: formatting

This commit is contained in:
zvon 2021-03-13 18:37:23 +01:00
parent 2f20661b5b
commit 594316dcea
5 changed files with 23 additions and 22 deletions

View File

@ -2,7 +2,10 @@
std::shared_ptr< SDLPP::Texture > TetrisBlock::block_texture = nullptr;
#ifdef FEATURE
const std::vector<SDL_Rect> blockanim = {{0,0,125,125}, {125,0,250,125}, {125,125,250,250}, {0,125,125,250}};
const std::vector< SDL_Rect > blockanim = { { 0, 0, 125, 125 },
{ 125, 0, 250, 125 },
{ 125, 125, 250, 250 },
{ 0, 125, 125, 250 } };
#endif
TetrisBlock::TetrisBlock( double x, double y, double w, double h,
@ -154,20 +157,18 @@ void TetrisPiece::rotate() {
auto &positions = pieces_rel_position[i];
auto piece_position = piece->getPos();
original_pos[i] = piece_position;
piece_position += { positions[0] * BLOCK_SIZE -
positions[1] * BLOCK_SIZE,
positions[2] * BLOCK_SIZE -
positions[3] * BLOCK_SIZE };
piece_position +=
{ positions[0] * BLOCK_SIZE - positions[1] * BLOCK_SIZE,
positions[2] * BLOCK_SIZE - positions[3] * BLOCK_SIZE };
auto bottom = positions[3];
auto top = positions[2];
positions[3] = positions[1];
positions[2] = positions[0];
positions[1] = top;
positions[0] = bottom;
piece_position += { positions[1] * BLOCK_SIZE -
positions[0] * BLOCK_SIZE,
positions[3] * BLOCK_SIZE -
positions[2] * BLOCK_SIZE };
piece_position +=
{ positions[1] * BLOCK_SIZE - positions[0] * BLOCK_SIZE,
positions[3] * BLOCK_SIZE - positions[2] * BLOCK_SIZE };
piece->setPos( piece_position );
}
}