import objectdraw.*; /** * A circle that falls vertically from a given point at a constant rate. */ public class FallingCircle extends ActiveObject { private static final int OVAL_SIZE = 20; private static final int FALL_SPEED = 1; private static final int PAUSE_MS = 10; private FilledOval oval; private double windowHeight; public FallingCircle(Location point, DrawingCanvas theCanvas) { oval = new FilledOval(point, OVAL_SIZE, OVAL_SIZE, theCanvas); windowHeight = theCanvas.getHeight(); start(); } public void run() { while (oval.getY() < windowHeight) { oval.move(0, FALL_SPEED); pause(PAUSE_MS); } } }