I'm trying to get the worms in my game to move away from the crabs when they're within a certain range. I have to use getObjectsInRange and a while loop. Here's my code:
public class Worm extends Animal
{
public void act()
{
runFromCrab();
}
public void runFromCrab()
{
while (getObjectsInRange(15, Crab.class))
{
move(15);
}
}
}
I keep getting errors when I try to compile. Any advice?
