TGC Codebase Backup



2D Button Principles by AxilGames

27th Jan 2004 16:45
Summary

This just detect places easier on screen using XPosition,Ypositions,Xwidth,Ywidth



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Free to use!  It's just code...

rem Global Arrays
dim detect(0)

rem Setup Screen
sync on

rem Use for your images or don't use to detect a certain part on screen

rem ****Let's say the width and height is 50x50****
load image "button.bmp",1
load image "buttonover.bmp",2

rem Make a cube for fun
make object cube 1,50

rem Main Loop
do

rem Mouse positions
mx=mousex()
my=mousey()

rem Paste button
paste image 1,320,200

rem Check for button
if mx=320 and my=200 or mx>320 and mx<370 and my>200 and my<250
detect(0)=1
paste image 2,320,200
endif

rem Check for mouseclick on button
if mouseclick()=1 and detect(0)=1
ghost object on 1
endif

rem Refresh Screen
sync

loop