for some reason line 32 wont execute and line 38 happens twice, which it should not.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class lobster here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class lobster extends Animal
{
public int speed = 1;
private boolean react = false;
/**
* Act - do whatever the lobster wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
chaseCrab();
}
public void chase()
{ turnTowards(Crab.crabX, Crab.crabY);
move(speed);
}
public void chaseCrab()
{
if(!react && !getObjectsInRange(200, foot.class).isEmpty())
{
move(speed);
react=true;
turn(180);
}
else
{
chase();
}
die();
}
public void die()
{
Actor foot = getOneIntersectingObject(foot.class);
if(foot!=null)
{ getWorld().removeObject(foot);
getWorld().removeObject(this);
}
}
}

