Here is some of my code:
PlayerInfo P1 = new PlayerInfo();
P1.setInfo(1);
System.out.println("" + P1.X + "," + P1.Y);
PlayerInfo P2 = new PlayerInfo();
P2.setInfo(2);
System.out.println("" + P1.X + "," + P1.Y);
PlayerInfo P3 = new PlayerInfo();
P3.setInfo(3);
System.out.println("" + P1.X + "," + P1.Y);
PlayerInfo P4 = new PlayerInfo();
P4.setInfo(4);
System.out.println("" + P1.X + "," + P1.Y);
Player Info is defined as:
public class PlayerInfo{
public static int Range;
public static int X;
public static int Y;
public static int Score;
public static int Lives;
private static ImageIcon image;
public PlayerInfo(int Num){
Range = 1;
if(Num == 1){
this.X = 0;
this.Y = 0;
//System.out.println("" + X + "," + Y);
image = new ImageIcon("H:\\My Pictures\\BomberMan\\BMBlack.png");
}
else if(Num == 2){
this.X = 16;
this.Y = 0;
//System.out.println("" + X + "," + Y);
image = new ImageIcon("H:\\My Pictures\\BomberMan\\BMWhite.png");
}
else if(Num == 3){
this.X = 0;
this.Y = 16;
//System.out.println("" + X + "," + Y);
image = new ImageIcon("H:\\My Pictures\\BomberMan\\BMRed.png");
}
else if(Num == 4){
this.X = 16;
this.Y = 16;
//System.out.println("" + X + "," + Y);
image = new ImageIcon("H:\\My Pictures\\BomberMan\\BMBlue.png");
}
Score = 0;
Lives = 3;
}
Right now my code is displaying:
0,0
16,0
0,16
16,16
when it should be displaying:
0,0
0,0
0,0
0,0
because the P1.X and P1.Y are initialized as 0 and 0 and are not supposed to be changed in my code. I have no idea why it is changing the P1.X and P1.Y values when I am not touching them at all. Can someone please explain this to me? Note: I have tried creating a separate method to set the information and an array of PlayerInfo's, but nothing works. Thanks in advance.