I made a game in Visual C#. It starts out with a welcome screen. After the game ends, it says "game over." Then I want the program to restart at the welcome screen like it was just started. How do I do that?
+1
A:
create a method to reset all variables and call the method used to start the game/display the start screen
Euclid
2009-11-30 01:48:58
+2
A:
Is this a serious question? Since you are coding in C#, have you looked at that language's syntax for loops? Things like while
or for
?
If neither works out for you, check out the GOTO statement - it is awesome (I know that - I used it a lot in my first Commodore C-64 programs back in 1985)! Just ignore the community content at the bottom of the MSDN page that the link above takes you to - the first person obviously does not know what he (or she) is talking about.
cdonner
2009-11-30 01:49:10
Oh you're evil. :)
Raj More
2009-11-30 01:58:10
Hardy har har. -1 vote.
Phenom
2009-11-30 02:05:37
@Benny: Never thought of that *slaps head*....damn that was short simple and sweet...look at my post!!!! :) Nice one!
tommieb75
2009-11-30 02:00:34
+3
A:
public void RunMyGame() { bool isFinish = false; while (!isFinish) { ShowWelcome(); InitVars(); PlayTheGame(); // We reach here when the game is finished // Play again? 'Y' isFinish set to false then loop isFinish = PromptToPlayAgain(); } }
Does this help?
Best regards, Tom.
tommieb75
2009-11-30 01:59:28