Here's some basic code to show how to handle unit selecting in an rts style game. It supports clicking a single unit, dragging a box to select multiple units and rts camera movement.
DBv1.x and DBPro compatible
Rem Project: RTS Basics by xtom
Rem Created: 02/01/2003 18:15:29
Rem ***** Main Source File *****
rem the following shows how to handle unit selection and camera movement for an rts game
rem it's setup for just 10 "units" but the method can be applied to 100's
rem this code should be DBv1 and DBPro compatible
rem setup unit selection array for 10 units
dim unit_selected(9)
rem setup 10 unit objects and place them randomly
for objectno=1 to 10
make object cube objectno,10
position object objectno,rnd(250)-125,0,rnd(250)-125
next objectno
rem set camera
camx#=0 : camz#=0
position camera camx#,200,camz#
xrotate camera 60
set camera range 100,400
rem setup sync rate
sync rate 60
sync on
do
rem mouse and arrowkey camera control
if selectbox=0 and (mousex()>screen width()-5 or rightkey()=1) then inc camx#,6
if selectbox=0 and (mousex()screen height()-5 or downkey()=1) then dec camz#,6
position camera camx#,200,camz#
rem unit selection code
if mouseclick()=1 and selectbox=0
rem deslect all units
for unit=0 to 9
unit_selected(unit)=0
next a
rem activate selection box
selectbox=1
selectboxstartx=mousex()
selectboxstarty=mousey()
endif
rem display selection box
if selectbox=1
ink rgb(255,255,255),0
if selectboxstartx=selectboxstartx and object screen x(unit+1)=selectboxstarty and object screen y(unit+1)=mousex() and object screen y(unit+1)=mousey() then unit_selected(unit)=1
if object screen x(unit+1)=mousex() and object screen y(unit+1)>=selectboxstarty and object screen y(unit+1)=selectboxstartx and object screen x(unit+1)=mousey() then unit_selected(unit)=1
next unit
selectbox=0
endif
endif
rem colour selected units red
for unit=0 to 9
if unit_selected(unit)=1
color object unit+1,rgb(255,0,0)
else
color object unit+1,rgb(255,255,255)
endif
next unit
rem display help text
text 0,0,"Left click to select a unit"
text 0,16,"Drag a box to select multiple units"
sync
loop