Tetris (8)
- Modify your previous TETRIS program
so that you can move a tetromino to left or right while it is falling
down.
-
Change the member functions Draw() and Erase() to become private.
- After a tetromino is constructed, automatically invoke Draw() to
display it.
- In Move(), invoke Erase() before the position of the tetromino is
modifed, and invoke Draw() after the position is modified.
- In Move(), add statements to handle the cases when it is called
with argument "left" or "right".
- left - decrement pos_x by 1, if it does not exceed the left
border.
- right - increment pos_x by 1, if it does not exceed the right
border.
- 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.
- 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.