Couple of minor bug fixes *ooops* and now highlights the selected matrix tile:
sync on
make object plain 1,0,0
hide object 1
make matrix 1,5000,5000,50,50
randomize matrix 1,25
update matrix 1
ink rgb(255,128,0),0
do
if upkey() then move camera 1
if downkey() then move camera -1
if leftkey() then turn camera left 1
if rightkey() then turn camera right 1
if shiftkey()
pitch camera up 90
move camera 1
pitch camera down 90
endIf
if controlkey()
pitch camera up 90
move camera -1
pitch camera down 90
endIf
rem Tile under mouse is?
nearRng=screen width()
selectedTileX=0
selectedTileZ=0
for tileX=1 to 50
for tileZ=1 to 50
x#=(tileX*100)-50
z#=(tileZ*100)-50
position object 1,x#,get ground height(1,x#,z#),z#
if object in screen(1)
dx#=abs(object screen x(1)-mouseX())
dz#=abs(object screen y(1)-mouseY())
rng=sqrt((dx#*dx#)+(dz#*dz#))
if rng<nearRng
nearRng=rng
selectedTileX=tileX
selectedTileZ=tileZ
endIf
endIf
next tileZ
next tileX
rem Highlight Tile
if selectedTileX>0
ulX=-1 : ulY=-1
urX=-1 : urY=-1
brX=-1 : brY=-1
blX=-1 : blY=-1
`Top Left
x#=(selectedTileX*100)-100 : z#=(selectedTileZ*100)-100
position object 1,x#,get ground height(1,x#,z#),z#
if object in screen(1)
ulX=object screen x(1)
ulY=object screen y(1)
endIf
`Top Right
x#=selectedTileX*100 : z#=(selectedTileZ*100)-100
position object 1,x#,get ground height(1,x#,z#),z#
if object in screen(1)
urX=object screen x(1)
urY=object screen y(1)
endIf
`Bottom Right
x#=selectedTileX*100 : z#=selectedTileZ*100
position object 1,x#,get ground height(1,x#,z#),z#
if object in screen(1)
brX=object screen x(1)
brY=object screen y(1)
endIf
`Bottom Left
x#=(selectedTileX*100)-100 : z#=selectedTileZ*100
position object 1,x#,get ground height(1,x#,z#),z#
if object in screen(1)
blX=object screen x(1)
blY=object screen y(1)
endIf
line ulX,ulY,urX,urY
line blX,blY,brX,brY
line ulX,ulY,blX,blY
line urX,urY,brX,brY
endIf
sync
loop
Pneumatic Dryll