I'm a student and i'm trying to do a game in Java with Slick2D, but i have a problem that i dont understand. I have some clases and from some i can get variables but in some i cant, and it all seems the same.
For example i have the class Gameplay where all gamelogic and render takes place:
public class Gameplay extends BasicGameState {
private GeneradorNiveles gen;
private ComprobadorColisiones comp;
private Player p;
private Bullet[] bAr;
private int bArpos;
private Bullet bala;
private boolean bActiva = false;
private int curBul = 0; 
private int MAXBALAS =50;
private Rectangle[] eRect;
private Rectangulo r;
private Input input;
private Random rnd;
private Enemy[] eAr;
private Enemy en;
private int eArpos;
private float curVel, curX;
private int MAXENE = 5;
private Image fondo;
private String ref = "res/fondo.png";
public Gameplay(){
}
@Override
public void init(GameContainer gc, StateBasedGame sbg)
        throws SlickException {
    comp = new ComprobadorColisiones();
    r = new Rectangulo();
    gen = new GeneradorNiveles();
    gen.init(gc);
    eRect = new Rectangle[MAXBALAS];
    rnd = new Random();
    p = new Player(300,500);
    fondo = new Image(ref);
    eAr = new Enemy[MAXENE];
    en = new Enemy();
    curVel= rnd.nextFloat();
    bAr =  new Bullet[MAXBALAS];
    bala = new Bullet();
    // Llena el array de eAr con enemigos//
    crearNuevosEnemigosY0();
    //
    //Llena el array b con las balas//
    llenarArrayBalas();
    //
}
@Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics g)
        throws SlickException {
    input = gc.getInput();
    fondo.draw(0, 0); // Dibujamos el fondo//
    p.render(gc, g); // Ejecuta el render del player //
    //For que carga todos los render de todas las balas
    for(Bullet bu : bAr){
        bu.render(gc, g);
        if(input.isKeyPressed(Input.KEY_SPACE)){
            bArpos = bu.getPos();
            bAr[curBul] = new Bullet(bala.getX(), bala.getY());
            curBul +=1;
            if(curBul >=MAXBALAS){
                curBul = 0;                 
            }
            if(bu.getY()<0){
                bAr[bArpos] = new Bullet(bala.getX(), bala.getY());
            }
        }
    }
    //For que carga todos los renders de todos los enemigos del array//
    for(Enemy en : eAr){
        en.render(gc, g);
        //If que comprueba si llega al final y crea otros nuevos
        if(en.getY()>600){
            eArpos = en.getPos();
            crearNuevoEnemigoMuerto(eArpos);
            //crearNuevosEnemigos();
        }
    }
}
@Override
public void update(GameContainer gc, StateBasedGame sbg, int delta)
        throws SlickException {
    comp.doy();
    p.update(gc, delta); // Ejecuta el update del player//
    //For donde hace el update de todas las balas del Array
    for(Bullet bu : bAr){
        bu.update(gc, delta);
    }
    input = gc.getInput();
    if(input.isKeyPressed(Input.KEY_ESCAPE)){
        Main.app.exit();
    }
    //Envia el valor de la x de la bala a la x de la b
    else if(input.isKeyDown(Input.KEY_SPACE)){
        bala.setX(p.getX()+20);
        bala.setY(p.getY());
        comp.setxEn(en.getX());
    }
    //
        //For donde hace el update de todos los enemigos de la Array
        for(Enemy en : eAr){
            try {
                en.update(gc, delta);
            } catch (InterruptedException e) {
                e.printStackTrace();
            };
        }
}
public void crearNuevosEnemigosY0(){
for (int i = 0; i < eAr.length; i++) {
    curVel= rnd.nextFloat();
    while(curVel>0.2f || curVel<0.1f){
        curVel= rnd.nextFloat();
    }
    eAr[i] = new Enemy(20+i*5, 0, i, curVel);
    }   
}
public void crearNuevoEnemigoMuerto(int eApos){
    curVel = rnd.nextFloat();
    curX = eApos*50/rnd.nextFloat();
    while(curVel>0.4f || curVel<0.1f){
        curVel= rnd.nextFloat();
    }
    while(curX<50 || curX>395){
        curX = rnd.nextInt(395);
    }
    eAr[eApos] = new Enemy(curX, 0, eApos, curVel);
}
public void llenarArrayBalas(){
    for (int i = 0; i < bAr.length; i++) {
        bAr[i] = new Bullet(i);
    }
}
@Override
public int getID() {
    return 0;
}
public int geteArpos() {
    return eArpos;
}
public void seteArpos(int eArpos) {
    this.eArpos = eArpos;
}
}
And those two:
Player class:
public class Player {
private Image pImg;
private String ref = "res/player.jpg";
private  float x,y;
private Bullet b;   
private int limite = 430;
private Input input;
private float vel = 0.5f;
boolean shoot = false;
public Player(){
}
public Player(float x, float y){
    this.x = x;
    this.y = y;
}
public void init(GameContainer gc) throws SlickException {
//  b = new Bullet();
}
public void render(GameContainer gc, Graphics g) throws SlickException {
    //pImg.draw(x,y);
    g.drawImage(new Image(ref), x, y);
    g.drawString(String.valueOf(x), 20, 30);
}
public void update(GameContainer gc, int delta) throws SlickException {
    input = gc.getInput();
    if(input.isKeyDown(Input.KEY_LEFT)){
        if(x>0){
            x -= vel * delta;
        }
    }else if(input.isKeyDown(Input.KEY_RIGHT)){
        if(x<limite){
            x += vel * delta;
        }
    }
}
public Input returnImput(){
    return input;
}
public boolean isShoot() {
    return shoot;
}
public void setShoot(boolean shoot) {
    this.shoot = shoot;
}
public float getX() {
    return x;
}
public void setX(float x) {
    this.x = x;
}
public float getY() {
    return y;
}
public void setY(float y) {
    this.y = y;
}
public float getVel() {
    return vel;
}
public void setVel(float vel) {
    this.vel = vel;
}
}
Enemy class:
public class Enemy  {
private GeneradorNiveles gen;
private Gameplay gp;
private float x, y;
private int pos;
private int eArpos;
private float vel = 0.5f;
private float velH = 0.2f;
private int valor = 1, contador ;
private String ref = "res/sE1.png";
private int aux;
private Rectangle eRect;
public Enemy(){
}
public Enemy(int eArpos){
    this.eArpos = eArpos;
}
public Enemy(float x, float y, int pos, float vel){
    this.x = x;
    this.y = y;
    this.pos = pos;
    this.vel = vel;
}
public void init(GameContainer gc) throws SlickException {
    gp = new Gameplay();
    gen = new GeneradorNiveles();
}
public void render(GameContainer gc, Graphics g) throws SlickException {
    g.drawImage(new Image(ref), x , y);
    //g.draw(eRect = new Rectangle(x,y,20,20));
}
public void update(GameContainer gc, int delta) throws SlickException, InterruptedException {
    animacionEnemigo(delta);
    //System.out.println(eArpos);
}
public void animacionEnemigo(int delta){
            contador += delta;
        switch(valor){
        case 1:
            x -= velH * delta;
            if((x)<50){
                contador = 6000;
            }
            break;
        case 2:
            x += velH * delta;
            if((int)x>395){
                contador = 6000;
            }
            break;
        }
        y += vel * delta; // Velocidad//
        if(contador>5000){
            contador = 0;
            if(valor == 1){
                valor = 2;
            }else if(valor == 2){
                valor = 1;
            }
        }
    pasarVar(); 
}
public void pasarVar(){
}
public float getX() {
    return x;
}
public void setX(float x) {
    this.x = x;
}
public float getY() {
    return y;
}
public void setY(float y) {
    this.y = y;
}
public int getPos() {
    return pos;
}
public Rectangle geteRect() {
    return eRect;
}
public void seteRect(Rectangle eRect) {
    this.eRect = eRect;
}
So i can get in other class the variables from player and not from enemy and i dont know what is wrong. Can someone help me?
Thank you
 
    