Hi
I am to design a hunters game in java which is going to be run from cmd(strictly no GUI) I have created a 12x12 array which is my board, I need to move my character using keys, and make a Hunter(NPC) move towards [0][0] from [12][12]. How do I store each players and hunters coordinates (To check for collisions etc)?
Java Code:
public class Hunters {
String [][] a2;
private static int score;
private static String player = "P";
private static String move;
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String [][]a2 = new String [12][12];
String emptyfield = "X";
score = 5;
for (int r = 0 ; r < a2.length; r++){
for (int c= 0; c <a2[r].length; c++){
a2 [r][c] = emptyfield;
a2[0][0] = player;
System.out.print(" "+a2[r][c]);
}
System.out.println("");
}
System.out.println("Input your move");
move = in.nextLine();
if (move.equalsIgnoreCase("w")){
//move up
//repaint
//check for collision
//check for health
}else if(move.equalsIgnoreCase("s")){
//move down
//repaint
//check for collision
//check for health
}else if(move.equalsIgnoreCase("d")){
//move right
//repaint
//check for collision
//check for health
}else if(move.equalsIgnoreCase("a")){
//move left
//repaint
//check for collision
//check for health
}
}
}
Thanks!