There are two ways you can do this without flicker.
Not using the backbuffer.
`Main Screen
`play or rules
LOAD BITMAP "background.jpg"
do
if buttons(275,240,"Play")>0 then buttonselected=1
if buttons(365,240,"Rules")>0 then buttonselected=2
if buttonselected=1 then goto welcome
if buttonselected=2
ink rgb(255,255,255),0
center text 320,300,"RULES"
endif
loop
end
function buttons(x,y,desc$)
buttonpressed=0
ink rgb(128,0,0),0 : box x-42,y-14,x+42,y+14
ink rgb(225,0,0),0 : box x-40,y-12,x+40,y+12
ink rgb(0,0,0),0
myx=mousex() : myy=mousey()
if myx>x-40 and myx<x+40
if myy>y-12 and myy<y+12
buttonpressed=1
endif
endif
if buttonpressed=1 then ink rgb(255,255,0),0
set text size 18 : center text x,y-8,desc$
if mouseclick()=0 then buttonpressed=0
endfunction buttonpressed
Welcome:
Using the backbuffer.
sync on
`Main Screen
`play or rules
LOAD BITMAP "background.jpg"
do
if buttons(275,240,"Play")>0 then buttonselected=1
if buttons(365,240,"Rules")>0 then buttonselected=2
if buttonselected=1 then goto welcome
if buttonselected=2
ink rgb(255,255,255),0
center text 320,300,"RULES"
endif
sync
loop
end
function buttons(x,y,desc$)
buttonpressed=0
ink rgb(128,0,0),0 : box x-42,y-14,x+42,y+14
ink rgb(225,0,0),0 : box x-40,y-12,x+40,y+12
ink rgb(0,0,0),0
myx=mousex() : myy=mousey()
if myx>x-40 and myx<x+40
if myy>y-12 and myy<y+12
buttonpressed=1
endif
endif
if buttonpressed=1 then ink rgb(255,255,0),0
set text size 18 : center text x,y-8,desc$
if mouseclick()=0 then buttonpressed=0
endfunction buttonpressed
Welcome: