Hi I want my character to move (on its own) until it hits a wall. When it hits a wall it should turn around and move in the other direction, and repeat.
Thank you in advance
public void movement() { if(turnTimer > 0) { turnTimer--; } else if(turnTimer == 0) { turnTimer = 5; } if(isTouching(Wall.class) && turnTimer > 0) { if(direction == 1) { direction = 0; } else { direction = 1; } turnTimer = 5; } if(direction == 1) { move(speed); if(animationCounter % 9 == 0) { animateRight(); } } if(direction == 0) { move(-speed); if(animationCounter % 9 == 0) { animateLeft(); } } }