// CS 2510 Spring 2011 // Lab 4: Follow.java import world.*; import image.*; import tester.*; // Represents a Cartesian point, X/Y come from the // super class, Posn. class CartPt extends Posn{ CartPt(int x, int y){ super(x,y); } /* Template: * Fields * ... this.x ... -- int * ... this.y ... -- int */ } // Represents a simple World where the location moves toward // a target, which is replaced on mouse clicks. class Follow extends World{ CartPt loc; CartPt targ; Follow(CartPt loc, CartPt targ){ this.loc = loc; this.targ = targ; } /********************************** * Need to design these methods... // Draw a dot, star, or something interesting at the location Scene onDraw(){ ... } // Move the location closer to the target // Motion equations: // lx' = lx + (tx - lx)/20 // ly' = ly + (ty - ly)/20 // Eventually (tx - lx)/20 will become 0, and motion "stops" Follow onTick(){ ... } // Reset the target location if "button-down" Follow onMouse(int x, int y, String me){ ... } */ } // Examples class FollowExamples{ FollowExamples(){} Follow start = new Follow(new CartPt(0,0), new CartPt(200,200)); World result = start.bigBang(); // Tests for methods... }