Tetris (8)

  1. Modify your previous TETRIS program so that you can move a tetromino to left or right while it is falling down.
  2. Change the member functions Draw() and Erase() to become private.
  3. After a tetromino is constructed, automatically invoke Draw() to display it.
  4. In Move(), invoke Erase() before the position of the tetromino is modifed, and invoke Draw() after the position is modified.
  5. In Move(), add statements to handle the cases when it is called with argument "left" or "right".
    1. left - decrement pos_x by 1, if it does not exceed the left border.
    2. right - increment pos_x by 1, if it does not exceed the right border.
  6. You may test your class with this main program. In addition to KEY_LEFT and KEY_RIGHT, the program also recognizes the key 'q' to quit the program. The program should produce output as follows.
    tetris-8.png
  7. Note that your program still has no idea about the previous tetrominoes, so it will always fall down to the bottom border, instead of stacking upon existing tetrominoes. We shall enhance this in the next version.
    tetris-8b.png