Due date: Thursday, February 10.
Ex. 1 Download the following files in a separate folder (you
don't want to mix the main.cc and the Makefile with those of another
program). The name of the executable is now "brickbreak":
Makefile
brickbreak.h
brickbreak.cc
ball.h
ball.cc
paddle.h
main.cc
Compile and run the program. You should see a red ball in the middle of the bottom border of the window that starts moving away.
a. Add another file called paddle.cc implementing the class Paddle for which you have only been given the definition. The paddle needs to be drawn as a simple rectangle. You will need to add this object to the Makefile in the list of objects.
b. Add a paddle object to brickbreak.cc. Initialize it in the function reset_obj() with the size and color that you want. The initial position for the paddle should be right underneath the ball - note that you need to move the ball up by the width of the paddle. In the function spkey, call the functions move_left and move_right on the paddle object with a value that you find appropriate (5?).
c. In the function move in the file brickbreak.cc, after moving the ball, test if it intersects the paddle, and if it does, bounce it back up. Since its attributes are declared as public, you can simply multiply its vertical speed by -1.
d. In the function key, for the case where the pressed key is the space, check if the y coordinate of the ball is lower than the negative of its radius (the same condition that makes it disappear off the screen in the function move). If that's the case, then call the function reset_obj() and then set the idle callback again to be the function move (note that when the ball is lost, this function becomes NULL which is a way to stop the animation).
Send me: the source file(s) that you modify, individual attachments by email. You don't need to send me the Makefile.