I'm trying to decide on how to structure my main game loop - every example I've seen of the game loop looks a bit like this:
while (true) {
UpdateGame();
DrawGame();
}
i.e. it ignores the menu. Should my game loop look like this:
if (ShowMenu() == Play) {
PlayGame();
}
PlayGame() {
while (true) {
UpdateGame();
DrawGame();
}
}
ShowMenu() {
while (true) {
HandleUserInput();
DrawMenu();
}
}
(I.e. the menu and game have separate loops), or should I structure my loop as such:
while (true) {
switch (state) {
case Menu:
MenuLoop();
break;
case Game:
GameLoop();
break;
}
}
GameLoop() {
HandleUserInput();
DrawMenu();
}
MenuLoop() {
HandleUserInput();
DrawMenu();
}
I.e. one big outermost loop. (or does it not really matter?)
For what its worth I'm using SDL / C (although I'd like to think that the question is language agnostic)