I've seen a few ppl do mouse clicking on a matrix by positioning an object. I think thats just a poor solution. (no offense intended to anyone)
It might've been my tutorial, im not aware of any other rts tutorials. I stopped doing a classic version because I moved onto DBP at that time and the new features made things easier.
Use right-click to get matrix coordinates at mouse, hold left-click to select objects. The mouse to matrix routine only works for a flat matrix and I'm not sure who the original author was. There's another method you can use but requires the enhancements for memblocks.
REM VARIABLES
screenwidth#=800
screenheight#=600
screenwidth2#=screenwidth#/2
screenheight2#=screenheight#/2
cspd#=6 : `camera x & y movement speed
cyspd#=4 : `camera height movement speed
cy#=350 : `starting camera height position
scalefactor#=screenheight#/1.2
REM SETUP
set display mode screenwidth#,screenheight#,32
sync on
`sync rate 0
backdrop on
color backdrop 0
REM MATRIX
make matrix 1,1000,1000,40,40
for t = 1 to 20
make object cube t, 20
position object t, rnd(500),0, rnd(500)
next t
make object sphere 100, 16
color object 100, rgb(255,0,0)
REM -------------------------------- MAIN LOOP ----------------------------
DO
gosub _Control_Camera
if mouseclick() = 0 then flag = 0:flag2=0
if mouseclick() = 2 and flag = 0
flag = 1
gosub _Click_Matrix_Position
position object 100,movex#,movey#,movez#
endif
if mouseclick() = 1 and flag2 = 0
flag2 = 1
oldx = mousex()
oldy = mousey()
endif
if flag2 = 1
newx = mousex()
newy = mousey()
rem draw selection box
drawBox(oldx,oldy,newx,newy,3)
rem loop through selectable objects
for i = 1 to 20
if pointInside(object screen x(i), object screen y(i),oldx,oldy,newx,newy) = 1
color object i, rgb(0,255,0)
else
color object i, rgb(255,255,255)
endif
next i
endif
sync
LOOP
rem checks if point 'P' is within the
rem inclusive coordinates
function pointInside(px,py,x1,y1,x2,y2)
rem make sure x1,y1 are the upper-left
if x1 > x2
temp = x1
x1 = x2
x2 = temp
endif
if y1 > y2
temp = y1
y1 = y2
y2 = temp
endif
if px>=x1 and px<=x2 and py>=y1 and py<=y2 then exitfunction 1
endfunction 0
rem draws an outlined box
function drawBox(x1,y1,x2,y2,thickness)
rem make sure x1,y1 are the upper-left
if x1 > x2
temp = x1
x1 = x2
x2 = temp
endif
if y1 > y2
temp = y1
y1 = y2
y2 = temp
endif
rem BOX is faster at drawing straight lines than LINE
rem and it allows for a variable line thickness this way
ink rgb(0,255,0),0
box x1,y1,x2,y1+thickness
box x1,y1,x1+thickness,y2
box x2-thickness,y1,x2,y2
box x1,y2-thickness,x2,y2
endfunction
REM CAMERA CONTROL AND MOVEMENT -------------------------------------------
_Control_Camera:
if upkey() then inc cz#,cspd#
if downkey() then dec cz#,cspd#
if rightkey() then inc cx#,cspd#
if leftkey() then dec cx#,cspd#
if scancode()=30 then inc cy#,cyspd#
if scancode()=44 then dec cy#,cyspd#
if cy#>400 then cy#=400
if cy#<200 then cy#=200
position camera cx#,cy#,cz#
rem for mouse clicking on a matrix to return the correct position,
rem these variables must match where the camera is pointed
offsetx#=cx#
offsety#=0
offsetz#=cz#+300
point camera offsetx#,offsety#,offsetz#
RETURN
REM gets co-ordinates on matrix of where mouse was clicked
_Click_Matrix_Position:
mouseposx#=mousex()-screenwidth2#
mouseposy#=screenheight2#-mousey()
dist#=sqrt((camera position x()-offsetx#)^2+(camera position y()-offsety#)^2+(camera position z()-offsetz#)^2)
if mouseposy#<>0
vectorang#=atanfull(scalefactor#,mouseposy#)
else
vectorang#=90.0
endif
if vectorang#+camera angle x()>90.965
ratio#=mouseposy#/(sin((vectorang#+camera angle x() )-90.0))
cursorposy#=ratio#*sin(180.0-vectorang#)
else
cursorposy#=1000000.0
endif
hyplength#=scalefactor#/sin(vectorang#)
cursorposx#=(((ratio#*sin(90.0-camera angle x() ))/hyplength#)+1.0)*mouseposx#
if mouseposx#<>0
angtotal#=wrapvalue(camera angle y()-atanfull(mouseposy#,mouseposx#))
else
if mouseposy#<0
angtotal#=wrapvalue(camera angle y()+90.0)
else
angtotal#=wrapvalue(camera angle y()-90.0)
endif
endif
cameraang#=wrapvalue(360.0-camera angle y() )
cosang#=cos(cameraang#)
sinang#=sin(cameraang#)
movex#=(dist#/scalefactor#)*((cosang#*cursorposx#)+((-1*sinang#)*cursorposy#))
movez#=(dist#/scalefactor#)*((sinang#*cursorposx#)+(cosang#*cursorposy#))
`\\\ 3D translated coords from 2D mouse coords \\\
movex#=movex#+offsetx#
movez#=movez#+offsetz#
movey#=0
RETURN
I still have the DBC code I started for the RTS.
http://zimnox.com/?page=dbTutorials