CS 105 Lab 9 -- Fall 1998

For your final Java lab (and your final CS 105 lab) you will achieve the ultimate goal of all too many beginning programmers -- making your very own video game. The actual goal, of course, will be to give you some personal experience with the element of Java (and programming in general) that we just finished discussing in class: repetition. Since animation is a natural application of repetition in a program, we will have you build your own version of one of the (if not the) original computer games, "pong".

A working version of the completed applet is included below so that you can understand its functionality (i.e. play with it). You can move the paddle back and forth by moving the mouse within the applet's screen region. The object is hit the little ball with the paddle each time it tries to sneak off the bottom of the playing area. If no ball is in play (i.e. you just started or you missed), you can get a new ball by clicking the mouse in the playing area.


This handout will lead you through the construction of such an applet. However, some of the Java details you will need to complete this task are not included here. Instead, they can be found in the "Java Programming with JavaTools" document. (The following link will take you to this JavaTools documentation .). You should bring the copies of this document (which I distributed for lab 3) with you when you come to lab this week.


To simplify printing, a version of the complete instructions for this lab as a single page is also available. Otherwise, follow the links below to read the remainder of this lab description.

If you have questions about the instructions for this lab, you are encouraged to ask them through the discussion area for this lab in the course discussion forum.


  • Preparation
  • Variable Declarations
  • Setting the Ball's Initial Position
  • Drawing the Ball
  • Moving the Ball
  • Bouncing
  • Adding a Paddle
  • Making the Paddle Useful
  • Getting a New Ball
  • Finishing Up