How to do turning as standart snake game. Turn always when you press arrow key 90 degrees.


private boolean pressingLeft = false; private boolean pressingRight = false; public void act() { if (Greenfoot.isKeyDown("left")) { if (!pressingLeft) { pressingLeft = true; setRotation(getRotation() - 90); } } else pressingLeft = false; if (Greenfoot.isKeyDown("right")) { if (!pressingRight) { pressingRight = true; setRotation(getRotation() + 90); } } else pressingRight = false; }