You might want to think it as a state machine. So that you have a main loop and what it runs depends on some state indicator. Something like this:



String gameState = "INITIALIZE"; // variable...