Rotate a Tetromino
- Modify CTetromino::Move() to consider the case when it receives an
argument "rotate". Add a case in the
switch state to handle rotations.
- In each tetromino, one square is chosen as the "center", which is
represented by (dy,dx) = (0,0). The location of this square will not be
changed after the rotation.
- For other tetrominoes, if the relative location to the center is
(dy,dx), then
- After rotating 180 degrees counterclockwise, the relative
location becomes (-dy, -dx).
- After rotating 90 degrees counterclockwise, the relative
location becomes (-dx, dy)
- After rotating 270 degrees counterclockwise, the relative
location becomes ( dx, -dy)
- Add a private data member "rotation" to your CTetromino class.
When rotation=i, it represents that the tetromino rotates 90*i degrees
counterclockwise.
- In the constructor, always set rotation = 0.
- In CTetromino::Move(), simply increment rotation by 1. This is
pretty simple.
- In CTetromino::Draw() and CTetromino::Erase(), you need to
consider the value of rotation to draw/erase the tetromino
correctly.
- You also need to modify update_occupy() and
detect_confliction().