CompSci 4
Java for Video Games

Classwork 3
Pong Modification

Introduction

Pong is arguably the first video game. Despite its apparent simplicity, there exist challenges in pong that still exist in many modern video games. In this assignment you will experiment with Pong and add some enhancements that will make the game more interesting.

For this homework, we encourage you to work with a partner rather than by yourself. Be sure to start early because this assignment can take much longer than the previous ones.

Requirements

How to

  1. Using Eclipse, snarf the project pongHW3 which contains the code for a slightly modified version of the Pong game.
  2. Run the program by running PongLoop. You can run PongLoop either as an applet or an application.
  3. Open the file PongLoop.java in the package pong and go to the method makeSprites where the ball is made. One line is commented out that would make a new YourSprite object. Uncomment this line (and comment out the line above it which is now redundant).
  4. Run the program again. You should see now YourSprite moving around instead of the StringSprite.
  5. Open the file YourSprite.java in the package pong.sprite and modify its constructor to make a more interesting sprite of your own design. It must Consult the class notes and/or SpriteTest example on the Gaming Engine Website for examples of CAG and General Path.
  6. Run the program again. You should now see the altered sprite moving around.
  7. Open the file ProjectileTracker.java in the package pong.tracker and go to the method advanceTime that changes the position. If you also change the velocity at every time step you can simulate the effect of gravity! At the beginning of the method, add the line
    velocity.y += 49 * time;
  8. Run the program again. You can experiment with different values for gravity to find one that makes the game interesting.
  9. Make the sound different when the ball hits different sprites (walls vs. paddles).
  10. Add two other enhancements of your choice. Try most simple suggestions before trying any advanced suggestions.
    Advanced suggestions include:
    1. Keep score.
    2. Make an artificially intelligent opponent. (E.g., a right paddle that never misses.)
    3. Make 2 balls. The balls could just pass through each other or, harder, also bounce off each other.
    Simple suggestions include:
    1. Significantly alter the paddles.
    2. Make the ball spin.
    3. Make the ball change colors when it bounces.

  11. When done, submit your assignment using Eclipse as pongHW3.
  12. Update your web page for this homework by posting your applet.