Hey guys. I just started using Greenfoot, and I was trying to make a code where you move a turtle with w,a,s, and d. And instead of just an image moving around, I wanted it to turn and face the direction it was going. I wrote the code, and it worked, for a little bit and then it stopped. Now it doesn't work. If I restart Greenfoot it works sometimes and then stops again. I've tried rewriting it a couple times and making it more efficient, but nothing works. Here's my code.
Thanks in advance for any help.
if (Greenfoot.isKeyDown("w")){
if (getRotation() != 270){
setRotation(270);
}
move(5);
}
if (Greenfoot.isKeyDown("s")){
if (getRotation() != 90){
setRotation(90);
}
move(5);
}
if (Greenfoot.isKeyDown("d")){
if (getRotation() != 0){
setRotation(0);
}
move(5);
}
if (Greenfoot.isKeyDown("a")){
if (getRotation() != 180){
setRotation(180);
}
move(5);
}


