Due date: Wednesday, February 16.
Download the tetris game composed of the following files:
Ex. 1 Edit the Tetris_brick class to
Ex. 2 Add a function in the main that rotates the brick if the
user presses the down key. The value of this key should be GDK_Down. You
will have to modify the function Event_press_key also.
This action in the game is a little bit more complex than the others because
you need to check if the brick can be rotated first, which means if the brick
with the new coordinates for the 4 pieces fits into the same position. My
suggestion is to copy the tetris_brick object into a second one using the
copy constructor, rotate the new one, check if this one fits into the same
position, and if it does, perform the rotation on the source one. You can
also implement the reverse rotation, then first rotate the object, check
if it fits in the table and if not, rotate it back. You must make sure that
the 2 functions are the exact inverse of each other.
Ex. 3 Modify the function that writes the brick to the table such that it checks if a whole row of bricks has been completed in the table (hint: you'll have to check this for each of the 4 pieces in the brick). Make the function return this number, then add it to a total score in the game as 10*nr_rows*nr_rows, where nr_rows is the number of rows completed by one brick. This means, if you complete 1 row at a time, you get 10 points, for 2 rows in the same time you get 40 points. Also add 1 point for each brick that is written to the table.
Note that when the user starts a new game you have to reset the score to 0.
Every time the score changes, you'll have to modify the status bar to show the new score (you don't have to keep the old message). This can be achieved by calling the function Change_statusbar with the argument being a string containing the score and eventually notifying the user when the game is over so they know to start a new one.
Send me: modified source files, including headers if needed.