TGC Codebase Backup



Simple Button by JoelJ

29th Dec 2003 21:51
Summary

makes a button at the given location



Description

call it like this:
camz# = button(buttonx-16, buttony-32, 16, 16, 101, 102, camz#, 1, mousex(), mousey())

(x, y, xsize, ysize, image_up, image_down, changing_var#, move, mousex, mousey)
x and y are where you want it to be, x/ysize are how many pixles your image is, image_up is the standard picture for the button (unpressed), image_down is when you click on the button, changing_var# is the varable that changes when you click the button, move is how much the varable changes by, mousex and mousey are the mouse coordinants.

it's very basic, but i find it very useful.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function button(x, y, xsize, ysize, image_up, image_down, changing_var#, move, mousex, mousey)
   if mousex > x and mousex < x + xsize and mousey > y and mousey < y + ysize
      paste image image_up, x, y
      if mouseclick() = 1
         paste image image_down, x, y
         changing_var# = changing_var# + move
      endif
   else
      paste image image_up, x, y
   endif
endfunction changing_var#