We present to your attention the code of the main menu. You can substitute your media files. The functions of drawing buttons were used as buttons.[functions -graham from darkbasic classic]
+ Code SnippetRem Project: MainMenuProject
Rem Created: Sunday, December 12, 2021
Rem ***** Main Source File *****
backdrop on : cls : sync on : sync rate 30 :
global WIDTH
WIDTH=DESKTOP WIDTH()
global HEIGHT
HEIGHT=DESKTOP HEIGHT()
SET DISPLAY MODE Width, Height, 32
SET WINDOW LAYOUT 0, 0, 0
SET WINDOW POSITION 0, 0
`disable escapekey
DISABLE SYSTEMKEYS
rem Setup Font
set text font "book" : set text size Height/20
set text to bold : set text transparent
Load image "MenuBackDrop.png",11
texture backdrop 11
paste image 11,0,0
`render
sync
get Image 13,0,0,WIDTH, HEIGHT,1
`render
sync
paste image 13,0,0
print "width=";width
print "height=";height
`paste image 11,0,0,1
SAVE IMAGE "1.png", 13
sync
cls
delete image 13
load image "1.png",13
paste image 13,0,0
sync
wait key
`end
rem place the button in the centre of the screen..
x=(screen width()/2)-37
y=(screen height()/2)-12
sync on
sync rate 30
_MainMenu:
NewGame=0:LoadGame=0:Options=0:hiscore=0:Quit=0:v=0
do
if NewGame=1 : wait 3000: goto _InGameMenu:endif
v=teststandardbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"New Game",2) : endcase
case 2 : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"New Game",1) : endcase
endselect
if v=2 then NewGame=1
if LoadGame=1: wait 3000:gosub _LoadGameMenu:NewGame=0:LoadGame=0:Options=0:hiscore=0:Quit=0:v=0:endif
v=teststandardbutton(x,y-height/15-height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"Load Game",2) : endcase
case 2 : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"Load Game",1) : endcase
endselect
if v=2 then LoadGame=1
if Options=1 : wait 3000:exit:endif
v=teststandardbutton(x,y,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y,width/10+width/10,height/15,"Options",2) : endcase
case 2 : creatbutton(x,y,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y,width/10+width/10,height/15,"Options",1) : endcase
endselect
if v=2 then Options=1
if Hiscore=1: wait 3000:exit:endif
v=teststandardbutton(x,y+height/15+height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"Hiscore",2) : endcase
case 2 : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"Hiscore",1) : endcase
endselect
if v=2 then Hiscore=1
if Quit=1: wait 3000:end:endif
v=teststandardbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"Quit",2) : endcase
case 2 : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"Quit",1) : endcase
endselect
if v=2 then Quit=1
sync
loop
_InGameMenu:
ResumeGame=0:LoadGame=0:saveGame=0:Options=0:Exit1=0:v=0
do
if ResumeGame=1 then wait 3000:exit
v=teststandardbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"Resume Game",2) : endcase
case 2 : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"Resume Game",1) : endcase
endselect
if v=2 then ResumeGame=1
if LoadGame=1 then wait 3000:Gosub _LoadGameMenu:ResumeGame=0:LoadGame=0:saveGame=0:Options=0:Exit1=0:v=0
v=teststandardbutton(x,y-height/15-height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"Load Game",2) : endcase
case 2 : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"Load Game",1) : endcase
endselect
if v=2 then LoadGame=1
if Options=1 then wait 3000:exit
v=teststandardbutton(x,y,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y,width/10+width/10,height/15,"Options",2) : endcase
case 2 : creatbutton(x,y,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y,width/10+width/10,height/15,"Options",1) : endcase
endselect
if v=2 then Options=1
if SaveGame=1 then wait 3000:gosub _SaveGameMenu:ResumeGame=0:LoadGame=0:saveGame=0:Options=0:Exit1=0:v=0
v=teststandardbutton(x,y+height/15+height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"Save Game",2) : endcase
case 2 : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"Save Game",1) : endcase
endselect
if v=2 then SaveGame=1
if Exit1=1 then wait 3000:Goto _MainMenu:
v=teststandardbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"Exit",2) : endcase
case 2 : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"Exit",1) : endcase
endselect
if v=2 then Exit1=1
sync
LOOP
end
_LoadGameMenu:
LoadGame1=0:LoadGame2=0:LoadGame3=0:LoadGame4=0:LoadGame5=0:v=0
for loop1=1 to 500
if LoadGame1=1: wait 3000:exit:endif
v=teststandardbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"Load Game 1",2) : endcase
case 2 : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"Load Game 1",1) : endcase
endselect
if v=2 then LoadGame1=1
if LoadGam21=1 : wait 3000:exit:endif
v=teststandardbutton(x,y-height/15-height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"Load Game 2",2) : endcase
case 2 : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"Load Game 2",1) : endcase
endselect
if v=2 then LoadGame2=1
if LoadGame3=1 : wait 3000:exit:endif
v=teststandardbutton(x,y,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y,width/10+width/10,height/15,"Load Game 3",2) : endcase
case 2 : creatbutton(x,y,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y,width/10+width/10,height/15,"Load Game 3",1) : endcase
endselect
if v=2 then LoadGame3=1
if LoadGame4=1 : wait 3000:exit:endif
v=teststandardbutton(x,y+height/15+height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"Load Game 4",2) : endcase
case 2 : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"Load Game 4",1) : endcase
endselect
if v=2 then LoadGame4=1
if LoadGame5=1 : wait 3000:exit:endif
v=teststandardbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"Load Game 5",2) : endcase
case 2 : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"Load Game 5",1) : endcase
endselect
if v=2 then LoadGame5=1
sync
next loop1
return
end
_SaveGameMenu:
savegame1=0:savegame2=0:savegame3=0:savegame4=0:savegame5=0:v=0
for loop1=1 to 500
if SaveGame1=1 then wait 3000:exit
v=teststandardbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"Save Game 1",2) : endcase
case 2 : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y-height/15-height/15-height/15-height/15,width/10+width/10,height/15,"Save Game 1",1) : endcase
endselect
if v=2 then SaveGame1=1
if SaveGame1=1 then wait 3000:exit
v=teststandardbutton(x,y-height/15-height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"Save Game 2",2) : endcase
case 2 : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y-height/15-height/15,width/10+width/10,height/15,"Save Game 2",1) : endcase
endselect
if v=2 then SaveGame2=1
if SaveGame3=1 then wait 3000:exit
v=teststandardbutton(x,y,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y,width/10+width/10,height/15,"Save Game 3",2) : endcase
case 2 : creatbutton(x,y,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y,width/10+width/10,height/15,"Save Game 3",1) : endcase
endselect
if v=2 then SaveGame3=1
if SaveGame4=1 then wait 3000:exit
v=teststandardbutton(x,y+height/15+height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"Save Game 4",2) : endcase
case 2 : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y+height/15+height/15,width/10+width/10,height/15,"Save Game 4",1) : endcase
endselect
if v=2 then SaveGame4=1
if SaveGame5=1 then wait 3000:exit
v=teststandardbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15)
select v
case 1 : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"Save Game 5",2) : endcase
case 2 : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"whoopee do",3) : endcase
case default : creatbutton(x,y+height/15+height/15+height/15+height/15,width/10+width/10,height/15,"Save Game 5",1) : endcase
endselect
if v=2 then SaveGame5=1
sync
next loop1
return
end
function teststandardbutton(x,y,width,height)
mx=mousex() : my=mousey() : v=0
rem find out wear the mouse pointer is..
if mx>x and mx<(x+width)
if my>y and my<(y+height)
rem mouse pointer over button.
rem button has been selected...
if mouseclick() then v=2 else v=1
update=1
endif
endif
rem set text opaque : ink 5356,rgb(192,192,192)
rem text x,y+50,str$(v)
endfunction v
function creatbutton(x,y,width,height,name$,tipe)
rem set-up colour palette, for this program
white=rgb(255,255,255)
black=0
grey=rgb(0,150,0)
yellow=rgb(0,255,0)
darkgrey=RGB(0,50,0)
bc=width/2
select tipe
case 2
rem draw preselected button
ink black,black
box x,y,(x+width),(y+height)
ink white,black
box x+1,y+1,(x+width)-2,(y+height)-2
ink black,black
box x+2,(y)+2,(x+width)-1,(y+height)-1
ink grey,black
box x+2,(y+2),(x+width)-2,(y+height)-2
rem ink text colour to yellow,
ink yellow,grey
endcase
case 3
rem draw standard button
ink black,black
box x,y,(x+width)-1,(y+height)-1
ink white,black
box x+1,(y)+1,x+width,(y+height)
ink darkgrey,black
box x+1,(y+1),(x+width)-1,(y+height)-1
rem ink text colour to yellow,
ink yellow,darkgrey
endcase
case default
rem draw standard button
ink white,black
box x,y,(x+width)-1,(y+height)-1
ink black,black
box x+1,(y)+1,x+width,(y+height)
ink grey,black
box x+1,(y+1),(x+width)-1,(y+height)-1
rem ink text colour to black,
ink back,grey
endcase
endselect
rem this the standard text set up for the buttons...
`set text font "Arial"
` set text size 12
if tipe>1
set text to bold
else
set text to normal
endif
set text transparent
center text x+bc,Y+5,name$
endfunction v
Suitable for any desktop size.
That's what I did.