I am creating a Java game where you fly a plane and save it from colliding with any obstacles, but I am facing problem with creating the Collisions and need assistance.

I am creating a Java game where you need to fly your plane, and save it from colliding with any obstacles. I have been able to do everything successfully, however the only problem I am facing is with creating Collisions.
Note: The compiler says 'Cannot find symbol' in class 'Bird' on lines 32-33.

//Fly Your Jet
import java.applet.*;
import java.awt.*;
public class Fly_Your_Jet_main extends Applet implements Runnable
{
    Thread thread = new Thread(this);
    boolean running = true;
    Player p;
    Bird b, b2, b3;
    Image dbImage;
    Graphics dbg;
    public void init()
    {
        setSize(1000,500);
        setBackground(Color.CYAN);
        p = new Player();
        b = new Bird(this);
        b2 = new Bird(900, 200, this);
        b3 = new Bird(100, 400, this);
    }
    public void start(){thread.start();}
    public void destroy(){running = false;}
    public void stop(){running = false;}
    public void run()
    {
        while(running)
        {
            repaint();
            p.update(this);
            b.update(this,p);
            b2.update(this,p);
            b3.update(this,p);
            try
            {
                Thread.sleep(20);
            }
            catch(InterruptedException e)
            {
                System.out.println("ERROR HAS OCCURRED");
            }
        }
    }
    public void update(Graphics g)
    {
        dbImage = createImage(1000, 500);
        dbg = dbImage.getGraphics();
        paint(dbg);
        g.drawImage(dbImage, 0, 0, this);
    }
    public void paint(Graphics g)
    {
        /*showStatus("Click on the ball and then press arrow keys to start playing!");
        g.setColor(Color.magenta);
        g.drawString("SAVE YOUR BALL!",170,15);*/
        p.paint(g);
        b.paint(g, this);
        b2.paint(g, this);
        b3.paint(g, this);
    }
}

Open in new window

//Fly Your Jet(Cont.)
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class Player implements KeyListener
{
    private int x1 = 450, y1 = 300, x2 = 415, y2 = 325, x3 = 435, y3 = 370, velX = 0, velY = 0;
    public void update(Fly_Your_Jet_main mc)
    {
        mc.addKeyListener(this);
        x1+=velX;
        y1+=velY;
        x2+=velX;
        y2+=velY;
        x3+=velX;
        y3+=velY;
    }
    public void paint(Graphics g)
    {
        //JET
        //JET BODY
        g.setColor(Color.PINK);
        g.fillOval(x1,y1,10,90);
        //JET WINGS
        g.setColor(Color.LIGHT_GRAY);
        g.fillRect(x2,y2,80,20);
        g.fillRect(x3,y3,40,10);
    }
    public void keyPressed(KeyEvent e)
    {
        switch(e.getKeyCode())
        {
            case KeyEvent.VK_RIGHT:
            {
                velX = 10;
                break;
            }
            case KeyEvent.VK_LEFT:
            {
                velX = -10;
                break;
            }
            case KeyEvent.VK_UP:
            {
                velY = -10;
                break;
            }
            case KeyEvent.VK_DOWN:
            {
                velY = 10;
                break;
            }
        }
    }
    public void keyReleased(KeyEvent arg0)
    {
        
    }
    public void keyTyped(KeyEvent arg0)
    {
        
    }
    public int getX()
    {
        return x1;
    }
    public int getY()
    {
        return y1;
    }
}

Open in new window


//Fly_Your_Jet(Birds)
import java.awt.*;
import java.net.URL;
public class Bird
{
    private int x = 5, y = 10,speed=10;
    private URL url;
    private Image bird;
    public Bird(Fly_Your_Jet_main mc)
    {
        url = mc.getDocumentBase();
        bird = mc.getImage(url, "Bird.jpg");
    }
    public Bird(int i, int j, Fly_Your_Jet_main mc)
    {
        url = mc.getDocumentBase();
        bird = mc.getImage(url, "Bird.jpg");
        x = i;
        y = j;
    }
    public void update(Fly_Your_Jet_main mc, Player p)
    {
        x+=speed;
        if(x<=0)
        speed = 10;
        else if(x>=mc.getWidth()-50)
        speed = -10;
        Collision(p);
    }
    private void Collision(Player p)
    {
        int PX = p.getX;//compiler says 'cannot find symbol'
        int PY = p.getY;//compiler says 'cannot find symbol'
        if(PX-32 <= x && PX+32 >= x)
        {
            System.out.println("Collision Detected!!!");
        }
    }
    public void paint(Graphics g, Fly_Your_Jet_main mc)
    {
        g.drawImage(bird,x,y,mc);
    }
}

Open in new window

Arkajyoti PalStudentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
int PX = p.getX;/

Open in new window


should be

int pX = p.getX();/

Open in new window


(Java variable names begin lower case)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Arkajyoti PalStudentAuthor Commented:
@CEHJ As per your suggestion, I tried putting 'pX' instead of 'PX', however, it did not resolve my problem.
CEHJCommented:
That was not the most important part of my comment. Have another look
Arkajyoti PalStudentAuthor Commented:
Thanks a lot for resolving my problem! It was really a silly mistake on my part. I didn't notice the brackets in getX().
CEHJCommented:
:)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Game Programming

From novice to tech pro — start learning today.