Hey all, i've made a lil snippet that does next stuff:
1) when you clicking the mouse, it shows grid lines
2) when u click on a box, it will drag&drop the box
3) when u click on the right-bottom curnor of the box, u will be able to re-size the box.
just made the code for one reason.. maybe it will help you guys with projects..
remstart
selection demo
remend
sync on
selected as byte
BoxX as Integer
BoxY as Integer
OldX as Integer
OldY as Integer
boxc1 as integer
boxc2 as integer
boxc3 as integer
boxc4 as integer
BoxSizeX as Integer
BoxSizeY as Integer
BoxSizeX = 350
BoxSizeY = 350
BoxSideToChange as Byte
randomize timer()
boxc1 = rgb(rnd(200)+55,rnd(200)+55,rnd(200)+55)
boxc2 = rgb(rnd(200)+55,rnd(200)+55,rnd(200)+55)
boxc3 = rgb(rnd(200)+55,rnd(200)+55,rnd(200)+55)
boxc4 = rgb(rnd(200)+55,rnd(200)+55,rnd(200)+55)
BoxX = 50
BoxY = 50
do
cls
text 0,0,"FPS: "+str$(screen fps())
`Set Box Size
if mouseclick()=1 and selected <> 1
if mousex()>BoxX and mousex()<BoxX+BoxSizeX
if mousey()>BoxY and mousey()<BoxY+BoxSizeY
if BoxX - Mousex() <= -BoxSizeX+50 and BoxX - Mousex() >= -BoxSizeX
if selected <> 3
selected = 3
OldX = MouseX()
OldY = MouseY()
endif
BoxSizeX = BoxSizeX + Mousex()-OldX
BoxSizeY = BoxSizeY + MouseY()-OldY
OldX = MouseX()
OldY = MouseY()
endif
endif
endif
`Move the Box
if mouseclick()=1 and selected <> 1 and selected <> 3
if mousex()>BoxX and mousex()<BoxX+BoxSizeX
if mousey()>BoxY and mousey()<BoxY+BoxSizeY
if selected <> 2
selected = 2
OldX = MouseX()
OldY = MouseY()
endif
BoxX = BoxX + Mousex()-OldX
BoxY = BoxY + MouseY()-OldY
OldX = MouseX()
OldY = MouseY()
endif
endif
endif
endif
`/Now for the BOX!!
box BoxX,BoxY,BoxX+BoxSizeX,BoxY+BoxSizeY,boxc1,boxc2,boxc3,boxc4
`Mouse + Selection
if mouseclick()=1 and selected = 0
OldX = mousex()
OldY = MouseY()
selected = 1
endif
`MOve The Selection line
if selected = 1 and mouseclick()=1
line OldX,OldY,Mousex(),OldY `upper line
line OldX,OldY,OldX,MouseY() `left line
line Mousex(),MouseY(),Mousex(),OldY `right line
line Mousex(),MouseY(),OldX,MouseY() `bottom line
endif
if mouseclick()=0
selected = 0
oldx = 0
oldy = 0
endif
sync
loop
- Enjoy