import objectdraw.*; import java.awt.*; public class FallingLogoCallbackTimed extends ActiveObject { // the delay between successive moves of the ball private static final int DELAY_TIME = 33; // number of pixels ball falls in a single move private static final double Y_SPEED = 4; private static final double PIXEL_SPEED = Y_SPEED/DELAY_TIME; // the image of the logo private VisibleImage logoGraphic; // the canvas private DrawingCanvas canvas; private LogoControllerCallbackTimed myController; public FallingLogoCallbackTimed(LogoControllerCallbackTimed master, Image logo, Location initialLocation, DrawingCanvas aCanvas) { canvas = aCanvas; logoGraphic = new VisibleImage(logo,initialLocation, canvas); myController = master; start(); } public void run() { double prevClock, now, elapsed; prevClock = System.currentTimeMillis(); while (logoGraphic.getY() < canvas.getHeight() ) { now = System.currentTimeMillis(); elapsed = now - prevClock; prevClock =now; logoGraphic.move(0, PIXEL_SPEED * elapsed); pause(DELAY_TIME); } myController.atBottom(this); logoGraphic.removeFromCanvas(); } }