import java.awt.*; public abstract class shape //this is the parent class for a shape that gravitates to a certain place { public int centerX, centerY, size, gravX, gravY; public double Xvel, Yvel; public boolean stopped; //sets the size, coordinates, initial velocity and ending coordinates. public shape(int x, int y, int size, int xVel, int yVel, int gravX, int gravY) { centerX=x; centerY=y; this.size=size; Xvel=(double)xVel; Yvel=(double)yVel; this.gravX=gravX; this.gravY=gravY; stopped=false; } public abstract void paint(Graphics g); //drawing method to be defined by child classes public void changevelocity() //changes the velocity to go one pixel in the direction of the ending coordinates { if (!stopped) { if (gravX != centerX) Xvel+=((gravX-centerX)/Math.abs(gravX-centerX))*10; if (gravY != centerY) Yvel+=((gravY-centerY)/Math.abs(gravY-centerY))*10; } } public void changeposition() //changes the coordinates according to the velocity values { if (!stopped) { centerX+=(int)(Xvel/10); centerY+=(int)(Yvel/10); Xvel=Xvel*.9; Yvel=Yvel*.9; if ((Math.abs(centerX-gravX)<=2) && (Math.abs(centerY-gravY)<=2) /*&& Math.abs(Xvel)<1.5 && Math.abs(Yvel)<1.5*/) stopped=true; //check to see if it's gravitated to it's final spot or close } else { centerX=gravX; centerY=gravY; } } //(because I have a basically constant acceleration, or a cheap simulation of it, the letters seem to 'gravitate' to the spots, //falling toward the ending point and seemingly getting caught by it's gravitational grip. public boolean isStopped() { return stopped; } //returns whether this shape is moving still }