private int[] target = null;
public void act()
{
if (Greenfoot.mousePressed(null))
{
MouseInfo m = Greenfoot.getMouseInfo();
target[0] = m.getX();
target[1] = m.getY();
}
if (target != null)
{
if (Math.sqrt(Math.pow(getX()-target[0], 2)+Math.pow(getY()-target[1], 2)) < 3) //close to target
{
target = null;
}
else
{
turnTowards(target[0], target[1]);
move(2);
}
}
}target = new int[2];