Pong       CPS 004.1, 29 July 2002

Named after its distinctive sound, Pong is generally considered the first popular computer game. It was developed by Atari in 1972 and had only two instructions: deposit quarter and avoid missing the ball for high score. It was an incredible hit and marked the beginning of the "arcade revolution". A description of this first arcade game is available here. A pictorial history of the game can be found here. An example is available online here.

Specifications

Your task is to write the classic arcade game Pong for a single player. In this variation, the player must keep the ball bouncing around the applet without letting it hit the bottom wall by moving a "paddle" along the bottom of the applet. If the ball hits the paddle it should bounce off the paddle as if it were a wall and the player's score should be incremented; if it misses then it reappear in random position and the player's score should be reset to 0. You should complete the following basic requirements:
  1. Make a ball that is 20x20 pixels, with a random position (somewhere above the paddle) and random velocity (initially pointed away from the paddle on the applet's bottom).
  2. Make a paddle that is 50x10 pixels, positioned in the center of the applet horizontally and 20 pixels from the applet's bottom vertically.
  3. Make bounce behaviors that causes the ball to bounce off the walls and the paddle.
  4. Make follow behaviors that causes the paddle's horizontal position to follow the mouse's horizontal position, but in no way goes beyond the applet's boundaries. Its vertical position should never change.
  5. Make a score in which one point is added each time it bounces successfully off of the paddle. The score should be reset to zero each time the ball bounces off the bottom wall (i.e., each time the paddle misses the ball).
  6. Make an applet class that creates a ball and a paddle and starts the game.
To be a true game there must be a high score, increasing challenge, and perhaps even more chances for points. Once you have made the basic game, you must do at least three of the following to distinguish your game from your classmates.
  1. Increasing speed. The ball's velocity should increase as the score increases. It should also be reset each time the ball hits the bottom wall.
  2. Shrinking paddle. The paddle's width should decrease as the score increases. It should also be reset each time the ball hits the bottom wall.
  3. High score. A second score should be added that keeps track of the maximum score reached during the game.
  4. Random bounces. The ball should bounce off the paddle in a random direction (away from the paddle) if the ball hits either end of the paddle (but not the center area).
  5. Multiple bouncing balls.
  6. Paddle velocity. Give the paddle a velocity that it imparts on the ball when they collide, i.e., when the paddle hits the ball when moving quickly, the ball bounces off the paddle with a higher speed.
  7. Lives. The player loses a life when the ball bounces off the bottom wall; when the number of lives reaches zero the game should stop.
  8. Scoring areas. Create some areas in the applet that can score bonus points if a ball hits them.
  9. Multiple paddles (one along each wall). All paddles should move in unison when the mouse moves.
  10. Computer controlled paddle. An opponent paddle opposite the player's that moves on its own to play pong. More credit will be given making it look more realistic, i.e., not simply moving the correct spot immediately and waiting for the ball (and perhaps even missing the ball once in a great while).

Advice

This program is a step up in size and complexity from the previous assignments, so it is more important than ever to think about the algorithms you will need before you write any code. Even more important though is that you code the program in small steps: do something well, then move on. Small victories will be very important to your morale in this assignment. There are many ways to approach this project, one way that we suggest is the following:

What to Submit

You have two days to complete this project; however, you must create a link to your applet from your CPS 4 web page today so that we can monitor your progress. You will only need to have one link on your page for the entire project, not each of the steps needed to complete it. At the end of each day, you and your partner should transfer the entire project folder created by Visual J++ to your respective public_html/cps4 folder in the acpub system.