I am having trouble getting my whale to turn back and go to the middle of the world and stay there from the bottom right corner.
public void move(double distance) { double angle = Math.toRadians(getRotation()); int x = (int) Math.round(getX() + Math.cos(angle) * distance); int y = (int) Math.round(getY() + Math.sin(angle) * distance); setLocation(x, y); }
//in your actor subclass; public void act() { if (getX() > getWorld().getWidth()/2 - 5 && getX() < getWorld().getWidth()/2 + 5 && getY() > getWorld().getHeight()/2 - 5 && getY() < getWorld().getHeight()/2 + 5) {//make your actor stop in the middle of the world; turnTowards(getWorld().getWidth()/2, getWorld().getHeight()/2); move(3); } }