Hello,
I need to give the worms a chance to survive! Have the worms respond to the “up” and “down” arrow keys on the keyboard by moving the worms left (for “up”) or right (for “down”) a random number of steps between 0 and 3. This is the following code but it is not responding. I need some help please.
public class Worm extends Actor
{
public void act()
{
if ( isAtEdge() )
{ turn(3);
}
if ( Greenfoot.getRandomNumber(100) < 10)
{
turn(Greenfoot.getRandomNumber(60) - 18);
}
move(3);
}
public void checkKeypress()
{
if (Greenfoot.isKeyLeft("up"))
{
turn(-3);
}
if (Greenfoot.isKeyRigh("down"))
{
turn(3);
}
}
}
