I have run the code multiple times in multiple scenarios and have gotten the same result. What it is supposed to do is move right, and when it hits the point it is supposed to turn, it turns. Instead, it gives me the error dialog box I instructed it to give when it hits something unidentified. It seems to be skipping the part of the code that tells it to execute a separate method. I have three other methods like this that do the same thing in different directions.
To detail how the situation works. I start the game and it loads the level with the player in it. I use some form of input that executes the code below. The character moves right, but then refuses to move even though the level says it should.
EDIT: I have amended the code to use .equals() instead of ==. I found that the problem actually arose with me forgetting how java does it's x and y axis. I thank those who fixed my flaw in coding though, it was really helpful.
public static void moveRight(){
move = true;
while(move == true){
Point character = load.getCharacter();
Point space = character;
space.x += 20;
String name = load.getSpace(space);
System.out.println(name);
if(name.equals("empty")){
load.setCharacter(space);
}else if(name.equals("fTurnUp")){
load.setCharacter(space);
move = false;
moveUp();
}else if(name.equals("fTurnDown")){
load.setCharacter(space);
move = false;
moveDown();
}else if(name.equals("fTurnLeft")){
load.setCharacter(space);
move = false;
moveLeft();
}else if(name.equals("fTurnRight")){
load.setCharacter(space);
move = false;
moveRight();
}else if(name.equals("turn")){
load.setCharacter(space);
move = false;
}else if(name.equals("finish")){
load.setCharacter(space);
move = false;
Component frame = null;
JOptionPane.showMessageDialog(frame,
"Congratulations! You have completed the level.",
"Level Completed",
JOptionPane.PLAIN_MESSAGE);
}else if(name.equals("wall")){
move = false;
Component frame = null;
JOptionPane.showMessageDialog(frame,
"The level was not designed correctly. Click 'Ok' to return to main menu",
"Invalid Level",
JOptionPane.ERROR_MESSAGE);
}
}
}