So, I am trying to
i. Turn the worms randomly left or right up to 18 degrees when they reach the end of the World.
ii. 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 up or down.
This is what I have so far, but every time I run the scenario, nothing happens! The worms don't move no matter how much I press the up and down keys. Can someone help me? I really have absolutely no idea what I am doing wrong.
"
import greenfoot.*;
/**
* Worm. A sand worm. Very yummy. Especially crabs really like it.
*/
public class Worm extends Actor
{
/**
* Check whether we are at the edge of the world. If we are, turn a bit.
* If not, do nothing.
*/
public void turnAtEdge()
{
if ( isAtEdge() )
{
turn(-18);
turn(18);
}
}
/**
* Check whether a control key on the keyboard has been pressed.
* If it has, react accordingly.
*/
public void checkKeypress()
{
if (Greenfoot.isKeyDown("left"))
{
move(3);
}
if (Greenfoot.isKeyDown("right"))
{
move(3);
}
}
}
"