TGC Codebase Backup



REPLY: NEED CODE FOR MENU BUTTONS by ZoneMaster

23rd Oct 2005 11:37
Summary

This is in reply to the previous code request for menu button when pressed prints "hello"



Description

This is in reply to the previous code request for menu button when pressed prints "hello". You can add to this however you like.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    sync on

do
buttonselected=0

if makebutton(320,240,"Hello")>0 then buttonselected=1

if buttonselected=1 then text 305,260,"Hello"

sync
loop

rem make buttons for commands
function makebutton(x,y,desc$)
   buttonpressed=0
   ink rgb(192,192,192),0 : box x-26,y-7,x+26,y+7
   ink rgb(128,128,128),0 : box x-24,y-5,x+24,y+5
   ink rgb(255,255,255),0
   myx=mousex() : myy=mousey()
   if myx>x-26 and myx<x+26
      if myy>y-7 and myy<y+7
         buttonpressed=1
      endif
   endif
   if buttonpressed=1 then ink rgb(64,64,64),0
   set text size 14 : center text x,y-7,desc$
   if mouseclick()=0 then buttonpressed=0
endfunction buttonpressed