Tetris: formatting
This commit is contained in:
parent
2f20661b5b
commit
594316dcea
@ -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 );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user