I want to know to code structure of a game that has different levels to choose from on the main screen. More precisely, I want to know how does the main loop hands off the rendering to another loop that exist in the level code.
I could think of a solution but I would like to know how this is done buyby game developers.
Solution:
// Level.cpp
void Level::LevelLoop() {
while(LevelNotDone){
handleInput();
update();
render();
}
}
// Main.cpp
void MainLoop() {
while(GameNotDone){
handleInput();
if (Condition to start level)
level.LevelLoop();
// wait until level loop exits
update();
render();
}
}