Here. Since I was so awestruck that someone chose MY code to base their project around, of all things, I decided to go ahead and implement some small tweaks. Nothing much, really. It fixes the issue you mentioned, and builds some additional button structure for you to look at/toy with. Currently, the DrawButton accepts two new arguments, basewidth and baseheight, that modify the button's actual width/height to a proportion of the screen size to a normal 640*480 display. For a button that is 100 wide and 20 tall at 640*480, the call would be DrawButton(x,y,100,20). Simple, eh? I thought so.
If you need anything else, just ask.
sync on
sync rate 30
//Pallette 909 Computer Color Constants
#CONSTANT col_white RGB(255,255,255)
#CONSTANT col_black RGB(0,0,0)
#CONSTANT col_red RGB(255,0,0)
#CONSTANT col_green RGB(0,255,0)
#CONSTANT col_blue RGB(0,0,255)
#CONSTANT col_cyan RGB(0,255,255)
#CONSTANT col_magenta RGB(255,0,255)
#CONSTANT col_yellow RGB(255,255,0)
//Pallette 909 Monochrome
#CONSTANT col_dimgray RGB(105,105,105)
#CONSTANT col_gray RGB(128,128,128)
_Main_Menu:
`remstart
DO
`Title
SET TEXT SIZE 200
SET TEXT FONT "agency fb"
INK rgb(255,255,255),0
CENTER TEXT Screen width() / 2, screen height() / 8, " Colony Alpha "
`Buttons
`Boxes
bx=SCREEN WIDTH()/8
by=SCREEN HEIGHT()/3
DrawButton(bx,by,150,30)
INC by,40
DrawButton(bx,by,150,30)
INC by,40
DrawButton(bx,by,150,30)
bx=(SCREEN WIDTH()/8)*5
by=SCREEN HEIGHT()/3
DrawButton(bx,by,150,30)
INC by,40
DrawButton(bx,by,150,30)
INC by,40
DrawButton(bx,by,150,30)
`-----------------------------------
SYNC
LOOP
FUNCTION DrawButton(x,y,widthbase,heightbase)
//We calculate these in advance to make things more simple later. You can of course just plug them in, if you'd like.
x1=x*(640/SCREEN HEIGHT())
y1=y*(480/SCREEN HEIGHT())
x2=x+(widthbase*(640/SCREEN HEIGHT()))
y2=y+(heightbase*(480/SCREEN HEIGHT()))
//Here is your ink function. I set up a constant because it's easier to read and remember.
INK col_gray,0
//This is an additional custom, if you'd like it. It does the two major button draw colors, right in the same command! :D
IF button_mouseover(x1,y1,x2,y2) THEN INK col_dimgray,0
IF button_pressed(x1,y1,x2,y2) THEN INK col_white,0
//Box draw, as usual
BOX x1,y1,x2,y2
//Another addition, the outline.
outline(x1,y1,x2,y2,col_black)
ENDFUNCTION
FUNCTION button_mouseover(x1,y1,x2,y2)
check AS BOOLEAN
IF x1<MOUSEX() AND x2>MOUSEX() AND y1<MOUSEY() AND y2>MOUSEY() THEN check=1 ELSE check=0
ENDFUNCTION check
FUNCTION button_pressed(x1,y1,x2,y2)
check AS BOOLEAN
IF button_mouseover(x1,y1,x2,y2)=1 AND MOUSECLICK()=1 THEN check=1 ELSE check=0
ENDFUNCTION check
FUNCTION outline(x1,y1,x2,y2,col)
INK col,col_black
LINE x1,y1,x2,y1
LINE x2,y1,x2,y2
LINE x1,y2,x2,y2
LINE x1,y1,x1,y2
ENDFUNCTION
EDIT: Here's my line of thinking for a very primitive version of a cascade, in a way that'll probably irk Phaelax to no end, seeing as the entire thing is hardcoded. For simple menus though, it ought to be great.
-Create a variable to know what level of the tree we're on.
-Create a variable to know which branch node we're on, I.E. new game, settings, etc.
-Reconstruct my code so that buttons are only highlight-able if they are in the current level, probably by dividing them into DrawButton and DrawDummyButton.
-Change bx for each button based on what level it's on. If you want them to slide smoothly, you'll need something like my Core Math Regulate code, which is below:
//To get something to transition, just store the current bx in a value, and regulate to the target.
//I.E.
//main_tree_bx=num_regulate(main_tree_bx,[TARGET],1)
//bx=main_tree_bx
//by=[Whatever by should be]
//[DRAW FUNCTIONS HERE]
FUNCTION num_regulate(a,b,spd)
FOR c=1 TO spd
IF b>a THEN INC a
IF b<a THEN DEC a
NEXT c
ENDFUNCTION a