CompSci 4
Java for Video Games
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
- Altering Sprites - make a more interesting ball.
- Altering Trackers - Pong is more fun with gravity, right?
- Add additional sounds - almost every game is better with sound
- Add other enhancements
How to
- Using Eclipse, snarf the project pongHW3
which contains the code for a slightly modified version of the Pong game.
- Run the program by running
PongLoop
. You can run PongLoop
either as an applet or an application.
- 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).
- Run the program again. You should see now
YourSprite
moving
around instead of the StringSprite
.
- 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
- be original: it must be something other than just a ball (sphere)
- use
CAG
(Constructive Area Geometry) or a
GeneralPath
- have color other than the default
Consult the class notes and/or
SpriteTest example on the Gaming Engine Website for
examples of CAG and General Path.
- Run the program again. You should now see the altered sprite
moving around.
- 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;
- Run the program again. You can experiment with different values for
gravity to find one that makes the game interesting.
- Make the sound
different when the ball hits different sprites (walls vs. paddles).
- Add two other enhancements of your choice. Try most simple
suggestions before trying any advanced suggestions.
Advanced suggestions include:
- Keep score.
- Make an artificially intelligent opponent. (E.g., a right
paddle that never misses.)
- Make 2 balls. The balls could just pass through each
other or, harder, also bounce off each other.
Simple suggestions include:
- Significantly alter the paddles.
- Make the ball spin.
- Make the ball change colors when it bounces.
- When done, submit your assignment using Eclipse as pongHW3.
- Update your web page for this homework by posting your applet.