Making a Game Menu

So, I am trying to make a function where the user can hit and a key and be taken to a menu system, much like a pause menu. But the issue is, I need to know how to go back to the line the code was at after executing the menu, if at all possible. Like, if they just finished some dialogue and went to the menu, when they exited, they would be taken back to after the dialogue. Any help would be appreciated.
Depending on the logic of your game, a pause menu would be rather simple to do. Assuming that you are making a graphical game and using a somewhat simple main game loop, the following is all that is needed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void Pause() //you may want to return something else to signal what the user chose to do
{
    //display menu and get input
}

//your game loop
while (Game.IsRunning())
{
    Game.Update();
    Game.Draw();

    if (KeyPressed(PauseKey)) //check for key press and pause, pretty simple
    Pause(); //code execution will return here after Pause() is done, pretty convenient

    Sleep(20);
}


Note: This code won't actually compile, its just to show you the basic logic of implementing a pause menu.
Topic archived. No new replies allowed.