Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Level::rotate()
- {
- Piece *tmp = current;
- // Move the piece if it needs some space to rotate
- int disX = max(posX + current->getHeight() - width, 0);
- // Go to next rotation state (0-3)
- int rotation = (current->getRotation() + 1) % PieceSet::NUM_ROTATIONS;
- clear(*current);
- current = pieceSet.getPiece(current->getId(), rotation);
- // Rotate successfully
- if (place(posX - disX, posY, *current))
- return true;
- // If the piece cannot rotate due to insufficient space, undo it
- current = tmp;
- place(posX, posY, *current);
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement