Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Waiting until condition

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Waiting until condition

    I'm attempting at making a small 2d game just because I'm bored.

    I am having an issue however. In the game, when two characters come next to each other, a fight begins. If the fight is with the human character, a JPanel below the map activates that is basically just the fight information and has a button for attacking. When the fight is over, there are a bunch of methods I need to call to clean up the looser and adjust the winner's stats.

    In order for that to work, I need to be able to tell my method that manages the battle to wait until one of the fighters loose. Based on my current setup, I have a method called getLooser() that returns either the player that lost or null which indicates neither has lost yet.

    I was thinking about doing a while(getLoose()==null) loop that does nothing, but it seems there should be a better way of doing this. Can anyone point me the correct direction?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Waiting until condition

    Not sure I fully understand the design, but can't you just have the battle class call a method in the manager class when the looser is set to something other than null?

Similar Threads

  1. Unable to retriving the data using WHERE condition
    By bhaskar_reddy in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: May 14th, 2010, 02:40 AM
  2. Replies: 4
    Last Post: April 27th, 2010, 01:18 AM
  3. Problem with condition
    By shamed in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 7th, 2009, 04:51 PM