I am trying to make a simple game that simulates ants inside a colony, in the Java language. They can move around the paths randomly, go outside to eat leaves, etc. The game is meant to be more of an exercise in programming logic, than an actual game, so I want to try to stay away from graphics, if at all possible. The idea I currently have is to use a 2D array, perhaps like:
public class Map {
int mapArray[][] = new int[5][5];
public static void main(String[] args) {
Map m = new Map();
}
public map() {
//Create the map
for(int x = 0; x < 5; x++) {
for(int y = 0; y < 5; y++) {
mapArray[y][x] = 0;
}
}
//Print the map
for(int x = 0; x < 5; x++) {
for(int y = 0; y < 5; y++) {
System.out.print(mapArray[x][y]);
}
System.out.println();
}
}
}
I would then do my logic based on the values at different positions in the array.
Is this the best way, or is there a different method that would work better than this one?