CS-360
Assignment # 4
Due Date: 10-27-08

In this assignment you are to make the following additions/modifications
to the "air hockey" game you began in the last assignment:

In the information/input area at the top of the window's client area add
three push button controls the user can press to give the ball any of three
different  colors; two standalone horizontal scroll bar controls for the 
user to change the velocity of the ball and of the paddle; a couple of 
label controls that label the scroll bars, and a couple more that 
continually show the score as the  game progresses.

In the same area, add a group box with two radio buttons giving the user
the choice of having the game played automatically (as in the past
assignment) or having it go into "user game-playing" mode in which the
user can move the paddle with either the mouse or using some keyboard 
keys. Details of how the mouse is used are up to you. One possibility is
to "drag" the paddle with a hand-shaped mouse cursor while the left mouse
button is down, but you may want to look into other possibilities.
Whatever you do, it should permit the user to move the mouse anywhere 
within the playing area and be as user-friendly and intuitive as possible.

Pressing the "y" keyboard key should cause the paddle to move a given
amount upward, the "b" key downward, the "g" to the left, and the "h" 
key to the right. You should change the function of the paddle-velocity 
scroll bar when the game is in "user game-playing" mode by allowing its 
setting determine how much the paddle moves in response to each key press 
by the user.

The paddle should be implemented as a bitmap or an image (something 
that looks like an air hockey paddle, perhaps from the internet, or 
design your own with a paint editor). In each frame of the animation 
all objects (background, ball, paddle, goals) should be drawn on an 
"offscreen shadow" image or bitmap, which should finally be drawn to 
the screen so that there is as little flicker as possible. This "double 
buffering" technique was explained in class.

The following is a snapshot of the game in action.



For extra credit, set things up so that when in "user game-playing" mode,
the x-component of the velocity of the ball after it is struck by the
paddle is changed by an amount that depends on the direction the paddle
was moving at the time of impact. The increment in the x-component of the
ball's velocity should be proportional to the x-component of the paddle's
velocity just prior to the collision. In other words, if the ball was
moving to the left and the paddle to the right just before impact, the
ball should rebound with a greater velocity toward the right than if the
paddle had been stationary. If the ball and paddle were both moving to
the left prior to impact, the ball should rebound with a reduced velocity
toward the right. If you implement this feature, you will also have to
cause the ball to "lose some velocity" (energy) every time it strikes a
vertical wall. (If not the ball's velocity could grow without bound after
many hits by the paddle.) You may also want to set an upper limit to the
ball's velocity so that it never will be permitted to move faster than
that value.