WTF? stupid code
remstart
The button function is called with parameters for the buttons position (x,y) and text.
It will return 1 if the button is leftclicked, and 2 if rightclicked.
remend
rem Button function
function button(x,y,t$)
rem Width and height of button
xx=x+text width(t$)+2
yy=y+text height(t$)+2
rem If mousecursor is over button
if 2dcollide(mousex(),mousey(),x,y,xx,yy)
rem If the button is clicked
if mouseclick()>0
rem Set value of mouseclick (leftclick/rightclick)
click=mouseclick()
rem Draw Clicked-button
ink rgb(50,50,50),0
box x,y,xx,yy
ink rgb(255,255,255),0
text x+1,y+1,t$
rem Wait until the mousebutton is released
repeat : until mouseclick()=0
rem Return mouselick-value
exitfunction click
else
rem Draw MouseOver-button
ink rgb(100,100,100),0
box x,y,xx,yy
ink rgb(190,190,190),0
text x+1,y+1,t$
endif
else
rem Draw button
ink rgb(190,190,190),0
box x,y,xx,yy
ink 0,0
text x+1,y+1,t$
endif
endfunction 0
rem Simple 2D collision function
function 2dcollide(x,y,x2,y2,x3,y3)
rem If the coordinate is within the right X-area
if x>x2 and x<x3
rem If the coordinate is within the right Y-area
if y>y2 and y<y3
rem Return a one
exitfunction 1
endif
endif
endfunction 0
Workers of all lands, Unite!