I am still fairly new to Java and I am having trouble finding a problem with this code.
I want myY and myX to set y and x, respectively.
Then I want to use x and y as to go to the correct location in the array room[][].
Once that is found, I want the variable place to be set as whatever the value in the [y][x] location is, namely 15.
I do not see why it is not doing what I want it to do. Any help is appreciated.
public class Rooms {
public static int myY = 2;
public static int myX = 1;
public static int x;
public static int y;
public static int place;
public static String roomTitle = "";
public static String roomDescription = "";
public static void direction( String d ){
// Converts input to coords
if (d.equals("NORTH")){
myY += 1;
}
if (d.equals("SOUTH")){
myY -= 1;
}
if (d.equals("EAST")){
myX += 1;
}
if (d.equals("WEST")){
myX -= 1;
}
if (d.equals("SPAWN")){
myX = 1;
myY = 2;
}
x = myX;
y = myY;
}
int room[][]={{0, 1, 2, 3, 4, 5, 6},
{7, 8, 9, 10,11,12,13},
{14,15,16,17,18,19,20},
{21,22,23,24,25,26,27},
{28,29,30,31,32,33,34}};
{ //what is this for?? Eclipse gives me an error without it?
place = room[y][x];
}
I want myY and myX to set y and x, respectively.
Then I want to use x and y as to go to the correct location in the array room[][].
Once that is found, I want the variable place to be set as whatever the value in the [y][x] location is, namely 15.
I do not see why it is not doing what I want it to do. Any help is appreciated.