Hi Yahfree,
You need to put a loop around your menu and game. Lets see if I can visualise this for you:
You have:
selection = 1 ; show main menu
Mainmenu() ; this shows the main menu if selection = 1
Once mainmenu ends, be it by clicking on "Options" or "Play game" then next line (Options()) runs.
If you clicked on Options, selection now equals 3 and the options menu is displayed.
If you didn't click on Options, the options() function runs but quits immediately.
After the options() function has ended, it continues to the rest of you game.
What you need is something like this: (note this is not actual useable code, just pseudo code)
selection = 1 ; open main menu first
The top "while not keyhit(1)" loop is not great practice to be honest and you would be better assigning a variable to control the running of this main loop so you can set it where you like in your code (based on a keypress or on a menu button press).
Hope this helps.
Tim
You need to put a loop around your menu and game. Lets see if I can visualise this for you:
You have:
selection = 1 ; show main menu
Mainmenu() ; this shows the main menu if selection = 1
Once mainmenu ends, be it by clicking on "Options" or "Play game" then next line (Options()) runs.
If you clicked on Options, selection now equals 3 and the options menu is displayed.
If you didn't click on Options, the options() function runs but quits immediately.
After the options() function has ended, it continues to the rest of you game.
What you need is something like this: (note this is not actual useable code, just pseudo code)
selection = 1 ; open main menu first
while not keyhit(1) ; loop until ESC is pressed if selection = 1 then mainmenu() ; main menu sets selection to 2 if the play game button is pressed or sets selection to 3 if the options button is pressed. elseif selection = 2 then playgame() ; move game code into its own function. When game ends set selection = 1 again to show the main menu. elseif selection = 3 then options() ; display the options menu. When the back button is pressed, set selection to 1 and the main menu will be shown. end if wend
The top "while not keyhit(1)" loop is not great practice to be honest and you would be better assigning a variable to control the running of this main loop so you can set it where you like in your code (based on a keypress or on a menu button press).
Hope this helps.
Tim