TGC Codebase Backup



Drawing an empty Box by Lucavi

29th Nov 2005 19:26
Summary

This code lets you draw an empty box on the screen using the left mouse button and dragging.



Description

This code lets you draw an empty box on the screen using the left mouse button and dragging. It is ideal for things such as selection tools, but calculating the area of the box, and then checking what objects are within it.



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

do

cls

if mouseclick() = 1
   if clicklastf = 0
      smousex = mousex()
      smousey = mousey()
      clicklastf = 1
   endif

   ink rgb(255, 255, 255), rgb(0, 0, 0)
   line smousex, smousey, mousex(), smousey
   line mousex(), smousey, mousex(), mousey()
   line mousex(), mousey(), smousex, mousey()
   line smousex, mousey(), smousex, smousey

endif

if mouseclick() = 0
   clicklastf = 0
endif

sync
loop