CompSci 6
Fall 2008
Program Design and Analysis

Animation: Making Moving Pictures

Animation, whether in the movies, cartoons, flipbooks, or even claymation, involves making small step-by-step changes to the characters and then displaying those changes rapidly enough to fool our eyes into seeing the motion as smooth. Today, you will be drawing shapes on the screen and making them move.The motion that you create will be algorithmic, i.e., based on the previous step, rather than hand-drawn or intelligent, but then that is what computers are best at.

We will use the following files in today's activity:

The first is the class you will be updating, the second simply starts the program by creating a frame in which to view the action (you will not need to update this class). You can use Eclipse to download these files to your machine by choosing the classwork project named animation. You should start by reading over the code in Canvas.java and making sure you understand it. When compiled and run, it should draw a red circle centered in the frame.

We will also refer to the following Java classes

You will update the code to make the circle move within the window bounds. When it reaches the edge of the window, it should "bounce", i.e., reverse its direction so that it looks like a perfectly elastic collision with a wall. To get to this point, we will go through the following steps:

  1. Move the circle straight to the right untils it disappears off the edge of the frame
  2. Reverse the circle's movement when it reaches the right edge
  3. Reverse the circle's movement when it reaches the left edge
  4. Allow the circle to move in both the horizontal and vertical direction
  5. Reverse the circle's movement when it reaches the top or bottom edge