I want to build a track editor, placing track pieces on the matrix grid.
If I have more than 1 box, how do I select the item and then move it, keeping the mouse cursor on the object?
`I want to build a track editor
`How can I click on objects to move them on screen, if I have more than 1 box?
`The up and down arrow keys move the camera up and down
`Click the mouse to move the block
`I am using DBPro
sync on
sync rate 200
global gridsize=20
global tracksizex=8
global tracksizez=16
global trackwidth=2
global tilesize=100
global gridx
global gridy
global gridz
global camx
global camy
global camz
global campointy
Make matrix 1,gridsize*tilesize,gridsize*tilesize,gridsize,gridsize
set camera range 1,10000
update matrix 1
WHITE=rgb(255,255,255)
ink WHITE,0
camx=(gridsize*tilesize)/2
camy=1700
camz=-100
campointy=-1800
position camera camx,camy,camz
point camera camx,campointy,2000
make object box 2,tilesize,tilesize,tilesize
oldmx=mousex()
oldmz=mousey()
gridx=1
gridz=1
do
objx=gridx*tilesize-(tilesize/2)
objy=tilesize/2
objz=gridz*tilesize-(tilesize/2)
position object 2,objx,objy,objz
set cursor 1,1:print "camx=";camx
set cursor 1,15:print "camy=";camy
set cursor 1,30:print "campointy=";campointy
if upkey()=1 then inc camy,10
if downkey()=1 then dec camy,10
if rightkey()=1 then inc camx,20
if leftkey()=1 then dec camx,20
if inkey$()="a" then inc campointy,2
if inkey$()="z" then dec campointy,2
`Question - How can I click on objects to move them on screen, if I have more than 1 box?
if mouseclick()=1
newmx=mousex()
newmz=mousey()
if newmx>(oldmx+20) then if gridx<gridsize then inc gridx,1:oldmx=newmx
if newmx<(oldmx-20) then dec gridx,1:oldmx=newmx
if newmz<(oldmz-20) then if gridz<gridsize then inc gridz,1:oldmz=newmz
if newmz>(oldmz+20) then if gridz>1 then dec gridz,1:oldmz=newmz
else
oldmx=mousex()
oldmz=mousey()
endif
position camera camx,camy,camz
point camera camx,campointy,2000
sync
loop
Any ideas would be helpful.
Thanks!
BillR