TGC Codebase Backup



Button Function by MikeS

12th May 2004 22:13
Summary

Easy function for creating buttons. Save loads of code with this button function. Even highlights code red!



Description

Easy function for creating buttons. Save loads of code with this button function. Even highlights code red!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    sync on : sync rate 60 `Setup our refresh rate
set text size 22       `Set the text size


do

`This tests our regular button.
Button("BUTTON TEST",10,20,10,150,20,30)


sync
loop



`Text represents what you'll see
`positionx represents where the text will fall on the x axis.
`positiony represents where the text will fall on the y axis.
`x1 represents what mousex must be greater than.
`x2 represetns what mousex must be less than.
`y1 represetns what the mouse y must be greater than.
`y2 represetns what the mouse y must be less than.

function Button(text$,positionx,positiony,x1,x2,y1,y2)
 ink rgb(255,255,255),1
 text positionx,positiony,""+text$
if mousex()>x1 and mousex()<x2 and mousey()>y1 and mousey()<y2
 ink rgb(255,0,0),1
 text positionx,positiony,""+text$
endif
endfunction