Rotate a Tetromino

  1. Modify CTetromino::Move() to consider the case when it receives an argument "rotate". Add a case in the switch state to handle rotations.
  2. 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.
  3. For other tetrominoes, if the relative location to the center is (dy,dx), then
    1. After rotating 180 degrees counterclockwise, the relative location becomes (-dy, -dx).
    2. After rotating 90 degrees counterclockwise, the relative location becomes (-dx, dy)
    3. After rotating 270 degrees counterclockwise, the relative location becomes ( dx, -dy)
  4. Add a private data member "rotation" to your CTetromino class. When rotation=i, it represents that the tetromino rotates 90*i degrees counterclockwise.
    1. In the constructor, always set rotation = 0.
    2. In CTetromino::Move(), simply increment rotation by 1. This is pretty simple.
    3. In CTetromino::Draw() and CTetromino::Erase(), you need to consider the value of rotation to draw/erase the tetromino correctly.
    4. You also need to modify update_occupy() and detect_confliction().