Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / simple button-function...

Author
Message
The Communist
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Cyberspace
Posted: 3rd Mar 2003 16:04
quite worthless really, maybe some n00b needs it...

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 xy2 and y
Workers of all lands, Unite!
The Communist
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Cyberspace
Posted: 3rd Mar 2003 16:05
WTF? stupid code



Workers of all lands, Unite!
The Communist
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Cyberspace
Posted: 3rd Mar 2003 16:06
and an example use of it:



Workers of all lands, Unite!
Dehrman
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location:
Posted: 4th Apr 2003 19:58
For the "simple button-function",

I must be a newbe cause every time I put it into my program I can't get it to work...It just says "IF EXPECTS AN INTEGER." I've substituted integers in for the x and y variables, but it still won't work. Can you describe (more detailed) how to use this function?

Login to post a reply

Server time is: 2024-11-24 05:07:34
Your offset time is: 2024-11-24 05:07:34