TGC Codebase Backup



Easy clickable menu without complicated variables by AnDrEy

18th Feb 2004 10:27
Summary

A fully explained, easy to use clickable menu (the invisible 1by1 sprite idea from the_winch in the 2d forum) Now supports multiple menus No media requiered.



Description

A fully explained, easy to use clickable menu (the invisible 1by1 sprite idea from the_winch in the 2d forum) Now supports multiple menus No media requiered.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem Coded by AnDrEy with 1by1 clickable sprite and msg$ display idea from the_winch
rem the background here
get image 1,0,0,1,1,1
rem replace box with your button
box 0,0,50,50
box 0,0,50,50
box 0,0,50,50
rem this makes the box into image
get image 2,0,0,50,50,1
get image 3,0,0,50,50,2
get image 4,0,0,50,50,3
cls
rem makes image into sprite
sprite 2,100,100,2
sprite 3,100,200,3
sprite 4,100,300,4
rem main loop
do
rem chechks collision on top button and the "none selected" msg$ message
  sprite 1,mousex(),mousey(),1
  if sprite hit(1,2) then msg$ = "menu 1" else msg$ = "none selected"
if msg$ = "menu 1" and mouseclick()=1 then text 10,10,"clicked on menu 1"

rem collision and message for the middle box

 if sprite hit(1,3) then msg$ = "menu 2"
if msg$ = "menu 2" and mouseclick()=1 then text 10,10,"clicked on menu 2"

rem collision and message for the lower box

if sprite hit(1,4) then msg$ = "menu 3"
if msg$ = "menu 3" and mouseclick()=1 then text 10,10,"clicked on menu 3"

rem prints out what you have selected and/not clicked on

  text 0,0,msg$

  rem loops (you need this)

loop