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 isCPUTurn= false;
isCPUTurn = true;
//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;
//Do player turn stuff
//end turn if all goes smoothly
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?
I am not pretty sure but You can try System.exit() .
Hope this help.
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.
I suppose that would work, thanks a lot dark =P
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.
I just opened a new thread with one that is making me claw at my eyes, so if you're able, please take a look.
Originally Posted by Dark