How do you switch 'scenes' in SFML? Example: From the menu to the game.
This is something that I have not seen anywhere :/
This is pretty simple, as long as the game/app isn't too insanely complex. Essentially the state of a program is stored in variables. So use a few to keep track of the scene:
int scene = 1; //Scene 1 is menu, 2 is game, etc. Only render certain things or run certain code/inputs if the scene is a certain integer. Example: only check for clicks on menu buttons if scene = 1.
bool running = false; //Only run the code for the primary game functions when running = true. This allows you to freeze the program.
bool reset = false; //You will see this later
In your main loop, on the game end, set running to false.
When the game starts, set running to true and scene to 2.
When you want to reset the game, set reset to true. Then you'll need an if statement, IN THE MAIN LOOP, like this:
if(reset == true)
{
//Reset the game variables to their original values
reset = false; //Make sure it doesn't reset every frame
}
Sorry if it's hard to understand, if you need help, just DM me and I can set up a tutorial.