C481 B581 Computer Graphics
Dana Vrajitoru
C481/B581 Homework 4

Due date: Monday, February 13, 2017.

Ex. 1 Download the following files in a separate folder (you don't want to mix with files from another program). The name of the executable is now brickbreak:
Makefile
brickbreak.h
brickbreak.cc
Ball.h
Ball.cc
Paddle.h
main.cc
glheader.h

Compile and run the program. You should see a red ball starting at the center bottom of the window and moving up at a randomized speed.

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 resetObj() 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 moveLeft and moveRight 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, in 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 resetObj() 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).

Ex. 2. (2 pts. extra credit) Implement a progressive movement for the paddle where the more you keep the arrow keys pressed, the faster the paddle moves, but when you release the arrow keys the movement speed is reset to a default.

Upload to Canvas: the source file(s) that you modify. You don't need to upload the Makefile.