I am trying to have a sound play whenever the crab in my scenario turns more than 18 degrees. This is what I have so far, but I have no idea how to make it so it only plays when it has turned more than 18 degrees. Can someone help me?
"
/**
* Check whether a control key on the keyboard has been pressed.
* If it has, react accordingly.
*/
public void checkKeypress()
{
if(Greenfoot.isKeyDown("left"))
{
turn(-4);
}
if(Greenfoot.isKeyDown("right"))
{
turn(4);
}
{
Greenfoot.playSound("Whip Crack-SoundBible.com-330576409.wav");
}
}
"