1 Replies - 2515 Views - Last Post: 22 February 2012 - 06:18 PM Rate Topic: -----

#1 MattRudd   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 22-February 12

Setting Boundaries for falling object game

Posted 22 February 2012 - 05:55 PM

Im currently in the process of creating a falling object game, where the player has to land the object in a certain position on the image at the bottom of the pane.

The planet surface image has a position where the object is safe to land. If the object lands anywhere else on that image, a JMessagePane will show that the mission has failed.

This is the code I Have allready which stops the object leaving the pane its held within:

public void run() {
    jPanel1.requestFocus();
    x = (int) p.getX();
    y = (int) p.getY();

    while (true) {
       lblShip.setLocation(x, y);
        y += sldSpeed.getValue();
        
        if (x > 670){
            x = 670;
        }
        if (y > 450){
            y = 450;
        }
        if (x < 0){
            x = 0;
        }
        try{
            Thread.sleep(100);
        } catch (InterruptedException e){
        }



Is there anyway that the object can have a preset landing area?

Anywhere else which it lands on the image will give a JMessagePane telling the player the mission has failed.

Is This A Good Question/Topic? 0
  • +

Replies To: Setting Boundaries for falling object game

#2 sukantobarua   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-February 12

Re: Setting Boundaries for falling object game

Posted 22 February 2012 - 06:18 PM

View PostMattRudd, on 22 February 2012 - 05:55 PM, said:

Is there anyway that the object can have a preset landing area?


I too would like to know the answer!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1