Results 1 to 4 of 4
- 04-20-2009, 09:08 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 57
- Rep Power
- 0
How to make a game quit in BlueJ after entering a room
I am new to BlueJ and programming and I have a game application that runs exactly how I want it too except I want the game to quit once I enter a room called "DungeonRoom" which extends the "Room" class. Here is my code for the DungeonRoom:
Currently when I try to run my game after adding the while statement it completely freezes and I have to Crtl-alt-delete End the task. Can anyone guide me on how I can have this game quit once I get into this room.Java Code:import java.util.ArrayList; public class DungeonRoom extends Room { private boolean isAlive = false; private boolean finished = false; /** * Constructor for objects of class DungeonRoom */ public DungeonRoom(String description) { super(description); while (! finished) { //Command command = parser.getCommand(); //finished = processCommand(command); if (hasDied()) finished = true; } System.out.println("Thank you for playing. Good bye."); } public boolean hasDied() {return isAlive == false;} public void die() {isAlive = false;} }
- 04-20-2009, 09:44 PM #2
System.exit(0) ends the program. I don't think it will close the game though.
Is your game displayed in a GUI or text based through command prompt or displayed in an IDE or what?Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- 04-20-2009, 09:49 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 57
- Rep Power
- 0
its using BlueJ in the terminal window so that would be command prompt, right?
- 04-20-2009, 09:53 PM #4
Member
- Join Date
- Mar 2009
- Posts
- 57
- Rep Power
- 0
Similar Threads
-
how to make mastermind game
By javabeginer in forum New To JavaReplies: 10Last Post: 04-14-2009, 02:11 AM -
Quit Button, Load new Frame, Timer Code
By IHateNetbeans in forum New To JavaReplies: 1Last Post: 03-18-2009, 03:58 PM -
Java Developer Needed/Perm/NJ/Brokerage...lots of room for growth
By shagans982 in forum Jobs OfferedReplies: 1Last Post: 08-09-2008, 11:55 AM -
help using BlueJ
By zoe in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:07 AM -
BlueJ 2.2.0
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-07-2007, 02:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks