Results 1 to 6 of 6
Thread: How do I "end" a game?
- 04-21-2011, 08:58 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 37
- Rep Power
- 0
How do I "end" a game?
Let's assume for a moment you're programming a game, how do you go about ending it in the event that the win condition is achieved? Right now, my rough idea is this. (this is all going to be pseudocode) I'm just putting this here to make sure my logic is sound before I try coding this in a few hours after I complete all my other game stuff
boolean isPlayerTurn=false;
boolean isCPUTurn= false;
boolean isGame=true;
while (isGame){
isCPUTurn = true;
while (isCPUTurn){
//do cpu turn stuff
//assuming it make it through everything
//Do I check for win conditions in each players loop, if so how do I break the loop since it's a nested while?
isCPUTurn = false;
}
isPlayerTurn= true;
while(isPlayerTurn){
//Do player turn stuff
//end turn if all goes smoothly
isPlayerTurn=false;
}
That's my current turn system in a nutshell, but lets assume that it's in the CPU turn and they score a winning hit, if I do an if that generates a break, won't it just break from the CPUTurn loop and not from isGame? Is my logic totally off here? Help?
- 04-21-2011, 12:47 PM #2
I am not pretty sure but You can try System.exit() .
Hope this help.Mak
(Living @ Virtual World)
- 04-21-2011, 02:20 PM #3
JFrame or console? Either way you could just call a method that checks to see if the winning hit was made. If yes, then call end game. Which depending on your method of display would differ.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 04-21-2011, 03:10 PM #4
Member
- Join Date
- Apr 2011
- Posts
- 37
- Rep Power
- 0
I suppose that would work, thanks a lot dark =P
- 04-21-2011, 03:15 PM #5
Personally thats how I'm doing it for my mini RPG I'm writing. If you need any more questions answered, feel free to ask.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 04-21-2011, 03:18 PM #6
Member
- Join Date
- Apr 2011
- Posts
- 37
- Rep Power
- 0
Similar Threads
-
connection = DriverManager.getConnection(DATABASE_URL,'"+userid +"','"+password+"');
By renu in forum New To JavaReplies: 3Last Post: 10-12-2010, 04:21 PM -
Implementing "Game Over" in Minesweeper game based on Gridworld framework.
By JFlash in forum New To JavaReplies: 2Last Post: 08-05-2010, 04:49 AM -
Java Applet Help - Making "Snake" Game
By Alphimeda in forum Java AppletsReplies: 15Last Post: 04-04-2010, 05:39 PM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 06:56 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks