I am working on the little-crab-5 scenario.
1. How do you make the crab give a certain sound after it turns more than 18 degrees?? It already moves when the left/right keys are pressed. What code am I supposed to add?
2. How can I make the lobsters eat every crab randomly? (Not always, but ever so often) I've already written the code for lobsters to eat them and make the crabs disappear.
Thanks for the help guys!
public void checkKeypress()
{
if (Greenfoot.isKeyDown("left"))
{
turn(-4);
}
if (Greenfoot.isKeyDown("right"))
{
turn(4);
}
}public void lookForCrab()
{
if ( canSee(Crab.class) )
{
eat(Crab.class);
Greenfoot.playSound("au.wav");
Greenfoot.stop();
}