I'm trying to setup a menu for my game. There's nothing special about this menu, in general, if you click on something, it should lead to a separate menu while clearing the first menu off the screen.
Currently, when I go to another menu, the first stays on the screen and gets in the way. Take a look.
dim savedGame(2,2);
gunLevel=0;
shieldLevel=0;
gosub menu;
menu:
`new game
if button2(200,150,"New Game")>0
gosub newGame;
endif
`continue game
`NOTE: Check to see if continue game is valid.
if button2(200,200,"Continue")>0
gosub continueGame;
endif
`options
if button2(200,250,"Options")>0
gosub options;
endif
`end game
if button2(200,400,"Exit")>0
end;
endif
goto menu;
return;
newGame:
savedGame(0,0)=0;
savedGame(0,1)=1;
savedGame(0,2)=2;
gosub levelOne;
return
continueGame:
load array "stats.dat",savedGame(2);
gunLevel=savedGame(1,0);
shieldLevel=savedGame(2,0);
`load the level
if savedGame(0,0)=0
gosub levelOne;
else
if savedGame(0,0)=1
gosub levelTwo;
else
if savedGame(0,0)=2
gosub levelThree;
endif
endif
endif
return;
options:
cls;
if button2(200,200,"Back")>0
goto menu;
endif
return;
levelOne:
return;
levelTwo:
return;
levelThree:
return;
` to make a button like button 2 (changes color when moused over)
function button2(x,y,content$)
colortheme = rgb(255,0,0);
pressed = 0;
tx = text width(content$) / 2;
ty = text height(content$) / 2;
if mousex() > x - tx and mousex() < x + tx;
if mousey() > y - ty and mousey() < y + ty;
pressed = 1;
endif
endif
if pressed = 1 then ink colortheme,0 else ink rgb(255,255,255),0
center text x,y - ty, content$;
if pressed > 0
pressed = mouseclick();
endif
endfunction pressed
"I will work harder... if you ask me enough times... or give me enough coffee"