You'll want a boolean variable that tells whether the game is paused or not and a key that toggles it. Check out this pseudocode:
disable escapekey
isPaused as boolean
pausedPressed as boolean `This is to stop the key from being repeatedly detected if it is held down
do
`Pause or unpause from user input
if keystate(76) `Replace with your pause key
if pausePressed = 0
isPaused = 1 - isPaused
pausePressed = 1
endif
else
pausePressed = 0
endif
`If the game isn't paused, do your game logic
if (isPaused = 0)
gosub DoGame
`If the game is paused, do your pause menu logic
else
gosub DoPause
endif
`Draw the game whether it is paused or not (so it can appear behind the pause menu)
gosub DrawGame
`Draw the pause menu on top of the game if the game is paused
if (isPaused = 1)
gosub DrawPause
endif
sync
loop
I apologize if I've snuck any C# syntax in there, I seem to be forgetting my DarkBASIC