Ok, so, here is my latest problem. I am now trying to make a game in which a standard algorithm is used for the actors movement. So i decided to make a maze game, in which the main actor always wants to keep a wall on its left, and won't go through wall, but just continue walking through the maze. I have only one possible solution to my maze, so it should end up working out. Any help for the code for wallOnLeft()???
public class Player extends Actor { private static final int EAST = 0; private static final int SOUTH = 90; private static final int WEST = 180; private static final int NORTH = 270; public Player() { getImage().scale(20,20); } public void act() { if(wallOnLeft()) { if(canMove()) { moveForward(); }else{ turnRight(); } }else{ turnLeft(); moveForward(); } } public boolean wallOnLeft() { int xOffset=0, yOffset=0; switch(getRotation()) { case EAST: xOffset=1;break; case SOUTH: yOffset=1;break; case WEST: xOffset=-1;break; case NORTH: yOffset=-1; } return getOneObjectAtOffset(xOffset, yOffset, Wall.class) == null; } public boolean canMove() { int xOffset=0, yOffset=0; switch(getRotation()) { case EAST: xOffset=1;break; case SOUTH: yOffset=1;break; case WEST: xOffset=-1;break; case NORTH: yOffset=-1; } return getOneObjectAtOffset(xOffset, yOffset, Wall.class) == null; } public void moveForward() { int dx=0, dy=0; switch(getRotation()) { case EAST: dx =1; break; case SOUTH: dy=1; break; case WEST: dx=-1; break; case NORTH: dy=-1; break; } setLocation(getX()+dx, getY()+dy); } public void turnRight() { switch(getRotation()) { case EAST: setRotation(SOUTH);break; case SOUTH: setRotation(WEST);break; case WEST: setRotation(NORTH);break; case NORTH: setRotation(EAST); } } public void turnLeft() { switch(getRotation()) { case EAST: setRotation(NORTH);break; case SOUTH: setRotation(EAST);break; case WEST: setRotation(SOUTH);break; case NORTH: setRotation(WEST); } } }