int value accessed from different class? java
<p>when i try to use the value of bulletX from a different class it does not give me the updated value.</p>

<p>i can change bulletX to static and it works but i have 2 subclasses of Shoot, and when both bullets are shot they freeze (while bulletX is static). below is the Shoot class and the class i am using to try to get the value of bulletX.</p>

<p>Shoot.java--------------------------------------------------------------    </p>

<pre><code>package Graphics;

import java.awt.Graphics;


public class Shoot extends Player{

    protected boolean shot;    
    protected int bulletX, bulletY;
    protected int lastPress;

    public void setBulletX(int bulletX) {this.bulletX = bulletX;}
    public int getBulletX() {return bulletX;}
    public void setBulletY(int bulletY) {this.bulletY = bulletY;}
    public int getBulletY() {return bulletY;}
    public void incBulletX(int i) {this.bulletX += i;}
    public void incBulletY(int i) {this.bulletY += i;}
    public boolean getShot() {return shot;}
    public void shot(boolean shot) {this.shot = shot;}

    protected void drawBullet(Graphics g) {        
        if(fireRate != 990 &amp;&amp; shot == true &amp;&amp; lastPress == 2) {      
            if(shot &amp;&amp; lastPress == 2) {
                g.fillOval(bulletX, bulletY, 5, 5);            
                incBulletX(fireRate);
            }

        }

        if(fireRate != 990 &amp;&amp; shot == true &amp;&amp; lastPress == 1) {

            if(shot &amp;&amp; lastPress == 1) {
                g.fillOval(bulletX, bulletY, 5, 5);
                incBulletX(-fireRate);
            }

        }
    }

}
</code></pre>

<p>BulletCollision.java--------------------------------------------</p>

<pre><code>package Graphics;

import java.util.logging.Level;
import java.util.logging.Logger;


public class BulletCollision extends Shoot{
    Player1 player1 = new Player1();
    Player2 player2 = new Player2();
    public void checkPlayerBulletCollide() {

        System.out.println(bulletX);
        if(player2.getBulletX() &gt; player1.getX()) {
            player2.decHealth(50);
        }
    }
}
</code></pre>

<p>Player.java-------------------------------</p>

<pre><code>package Graphics;

public abstract class Player {
    protected int x, y;

    protected int playerSpeed;
    protected int fireRate = 990;
    protected int jumpHeight;
    protected boolean jump;
    protected int health;

    public void setHealth(int health) {this.health = health;}
    public int getHealth() {return health;}
    public void decHealth(int i) {this.health -= i;}    
    public void jumpable(boolean b) {this.jump = b;}
    public boolean canJump() {return jump;}
    public void incX(int i) {this.x += i;}
    public void setX(int x) {this.x = x;}
    public void incY(int i) {this.y += i;}
    public void setY(int y) {this.y = y;}
    public int getX() {return x;}
    public int getY() {return y;}
    public int getFireRate() {return fireRate;}
    public int getJumpHeight() {return jumpHeight;}
    public int getPlayerSpeed() {return playerSpeed;}
    public void setPlayerSpeed(int playerSpeed) {this.playerSpeed = playerSpeed;}  
    public void setFireRate(int fireRate) {this.fireRate = fireRate;}
    public void setJumpHeight(int jumpHeight) {this.jumpHeight = jumpHeight;}

    public void canJump(boolean jump) {this.jump = jump;} 

}
</code></pre>

<p>(please note i made lots of these classes extend each other so i can extend one of them and have access to all of them)</p>

<p>this is Player2.java-----------------------------------------</p>

<pre><code>package Graphics;

import Display.DrawArea;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;


public class Player2 extends Jump implements KeyListener{


    public Player2() {
        jumpingThread.start();
        setHealth(500);
        setX(600);
        setY(600);
        setPlayerSpeed(12);
        setFireRate(25);
        //setBulletX(5);
        setBulletY(500);
        setJumpHeight(70);
        setJumpInc(2);
        jumpable(true);

    }

    public void drawPlayer2(Graphics g) {
        g.setColor(Color.CYAN);
        g.fillOval(getX(), getY(), 30, 30);
        g.fillOval(getX(), getY(), 30, 30);       


        drawBullet(g);

        checkBulletCollide();
        g.setColor(Color.red);
        g.drawString("--" + getHealth() + "--", getX(), getY() - 10);

    }

    @Override
    public void keyTyped(KeyEvent ke) {

    }

    @Override
    public void keyPressed(KeyEvent ke) {
        //left
        if(ke.getKeyCode() == KeyEvent.VK_A) {
            System.out.println("left");
            if(!shot) {
                lastPress = 1;
            }

        if(getX() &gt; LEFT_WALL) {            
            incX(-getPlayerSpeed());
        }

        }

        //right
        if(ke.getKeyCode() == KeyEvent.VK_D) {

            if(!shot) {
                lastPress = 2;
            }

            if(getX() &lt; RIGHT_WALL ) {
            incX(getPlayerSpeed());
            }
        }

        //jump
        if(ke.getKeyCode() == KeyEvent.VK_W) {
            jumping = true;


        }

        //down
        if(ke.getKeyCode() == KeyEvent.VK_S) {
            if(getY() &lt; BOTTOM_WALL) {
            incY(getPlayerSpeed());
            }
        }

        //shoot
        if(ke.getKeyCode() == KeyEvent.VK_F) {
            if(getShot() == false) {
            setBulletY(getY());
            setBulletX(getX());
            shot(true);
            }
        }


    }

    @Override
    public void keyReleased(KeyEvent ke) {

    }

}
</code></pre>

<p>Player1.java-----------------------------------------------</p>

<pre><code>package Graphics;

import Display.DrawArea;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;


public class Player1 extends Jump implements KeyListener{


    public Player1() {
        jumpingThread.start();

        setHealth(500);
        setX(100);
        setY(600);
        setPlayerSpeed(12);
        setFireRate(25);
        setBulletX(5);
        setBulletY(500);
        setJumpHeight(70);
        setJumpInc(2);
        jumpable(true);

    }

    public void drawPlayer1(Graphics g) {

        g.setColor(Color.GREEN);
        g.fillOval(getX(), getY(), 30, 30);
        g.fillOval(getX(), getY(), 30, 30);


        drawBullet(g);
        checkBulletCollide();

        g.setColor(Color.red);
        g.drawString("--" + getHealth() + "--", getX(), getY() - 10);

    }

    @Override
    public void keyTyped(KeyEvent ke) {

    }

    @Override
    public void keyPressed(KeyEvent ke) {
        //left
        if(ke.getKeyCode() == KeyEvent.VK_LEFT) {
            if(!shot) {
                lastPress = 1;
            }

        if(getX() &gt; LEFT_WALL) {            
            incX(-getPlayerSpeed());
        }

        }

        //right
        if(ke.getKeyCode() == KeyEvent.VK_RIGHT) {

            if(!shot) {
                lastPress = 2;
            }

            if(getX() &lt; RIGHT_WALL ) {
            incX(getPlayerSpeed());
            }
        }

        //jump
        if(ke.getKeyCode() == KeyEvent.VK_UP) {
            jumping = true;


        }

        //down
        if(ke.getKeyCode() == KeyEvent.VK_DOWN) {
            if(getY() &lt; BOTTOM_WALL) {
            incY(getPlayerSpeed());
            }
        }

        //shoot
        if(ke.getKeyCode() == KeyEvent.VK_SHIFT) {
            if(getShot() == false) {
            setBulletY(getY());
            setBulletX(getX());
            shot(true);
            }
        }


    }

    @Override
    public void keyReleased(KeyEvent ke) {

    }

}
</code></pre>

<p>in BulletCollision i would prefer to get the value like this way: player1.getBulletX() so i can have different values. please can somebody help me with this</p>
