My problem is that as soon as I hit a wall, my object just stops moving but it does not turn around.
import greenfoot.*; public class enemy extends Actor { int i; public void act() { moveAround(); } public boolean hitWall() { if (isTouching (walls.class)) { return true; } else { return false; } } public void moveAround() { move(3); if(isTouching (walls.class)==true) { move(-3); int i = Greenfoot.getRandomNumber(3); } if(i==1) { setRotation(90); i=0; } if(i==2) { setRotation(-90); i=0; } } }