Pressable buttons by Maxmacster11th Dec 2005 18:57
|
---|
Summary Pressable buttons using BOX and TEXT commands Description This will allow you to create raised buttons with an embossed like text using BOX and TEXT commands (no need for sprites or images!). The buttons are 'pressable'. Im sure that this could be adapted to run smoother by using FUNCTIONS or a GOSUB routine. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Project: BUTTON CODE Rem by Maxmacster set display mode 800,600,16 set text font "tahoma" set text size 13 SET TEXT TO BOLD CLS `YOU WILL NEED AS MANY OF THESE BUTTON CO-ORDINATES `FOR HOW MANY BUTTONS YOU NEED GLOBAL Ax=16 :`start of button A GLOBAL Ay=32 :`start of button A GLOBAL ALNG=64 :`length of button A GLOBAL ADPT=16 :`depth of button A `GLOBAL Bx=16 :`start of button B `GLOBAL By=48 :`start of button B *NOTE THIS WILL OFFSET BUTTON B IN THE 'Y' DIRECTION `GLOBAL BLNG=64 :`length of button B `GLOBAL BDPT=16 :`depth of button B `**** main program **** SYNC DO MX=MOUSEX() MY=MOUSEY() MC=MOUSECLICK() GOSUB COLOURS `BACKGROUND BOX box 0,0,799,599,LG,LG,LG,LG: `HIGHLIGHT box 2,2,799,599,DG,DG,DG,DG: `SHADOW box 2,2,797,597,g,g,g,g: `MAIN COLOUR `SECONDARY BOX TP=8: `TOP LF=8: `LEFT RG=128: `RIGHT BT=144: `BOTTOM box TP,LF,RG,BT,LG,LG,LG,LG: `HIGHLIGHT box TP+1,LF+1,RG,BT,dg,dg,dg,dg: `SHADOW box TP+1,LF+1,RG-1,BT-1,g,g,g,g: `MAIN COLOUR `DRAW BUTTON AND CHECK FOR MOUSE CLICK box Ax,Ay,Ax+ALNG,AY+ADPT,W,W,W,W box Ax+1,Ay+1,Ax+ALNG,Ay+ADPT,B,B,B,B box Ax+1,Ay+1,Ax+ALNG-1,Ay+ADPT-1,LG,LG,LG,LG ink W,B center text (ALNG-Ax)+1,Ay+1,"BUTTON" ink DG,B center text ALNG-Ax,Ay,"BUTTON" `MOUSECLICK CHECK IF POSITIVE THEN DRAW PRESSED BUTTON IF MC=1 THEN IF MX>=AX THEN IF MX<AX+ALNG THEN IF MY>=AY THEN IF MY<AY+ADPT box Ax,Ay,Ax+ALNG,AY+ADPT,B,B,B,B box Ax+1,Ay+1,Ax+ALNG,Ay+ADPT,W,W,W,W box Ax+1,Ay+1,Ax+ALNG-1,Ay+ADPT-1,G,G,G,G ink B,B center text (ALNG-Ax)+2,Ay+2,"BUTTON" ink W,B center text (ALNG-Ax)+1,Ay+1,"BUTTON" ENDIF LOOP COLOURS: w=rgb (255,255,255): `white b=rgb (0,0,0): `black g=rgb (128,128,128): `grey dg=rgb (48,48,48): `dark grey lg=rgb (192,192,192):`lightgrey RETURN |