Really just the mouse, camera, and push scroll system from OIE.
Would work in DBC with a little modification. Note that this does not use the Pick Object command set, it just positions an object wherever you click, easy to impliment though.
+ Code Snippet`RTS Mouse control demo by Van-B (DBPro)
`Note - would work in DBClassic with some minor modifications (mainly using an array for the globals)
`This system uses 0 as the lowest level - I like to use 0 as the water height, so when you click water,
`you click the surface of the water instead of underneath.
sync on : sync rate 0 : autocam off
`Globalised variables for MUS function
global musx#
global musy#
global musz#
`Make a test texture
cls rgb(0,255,0)
ink rgb(0,32,0),rgb(0,32,0)
box 1,1,31,31
get image 1,0,0,32,32
ink rgb(255,255,0),0
`Simple matrix
make matrix 1,6400,6400,64,64
prepare matrix texture 1,1,1,1
randomize matrix 1,100
update matrix 1
yang=0
`Object 2 is the fake mouse pointer, but it can be reused for other calculations too
make object cube 2,50 : hide object 2
`Object 3 is moved with the left mouse button
make object sphere 3,50
hide mouse
`Default camera start location
camy#=500
camx#=3200
camz#=3200
`Main loop
do
mx=mousex()
my=mousey()
mc=mouseclick()
if leftkey()=1 then yang=wrapvalue(yang-1)
if rightkey()=1 then yang=wrapvalue(yang+1)
if upkey()=1 then inc camy#,10
if downkey()=1 then dec camy#,10
gosub calc_camera
gosub calc_mouse
`Scale the ball, just to show the accuracy better
scale=abs(sin(timer()/6.0)*100)
scale object 3,scale,scale,scale
sync
loop
calc_mouse:
`Calculate the MMZ# and MMX# as 0.0-1.0 floating point variables
mmz#=(((my*1.0)/(screen height()*1.0))-1.05)*(camy#*2.10)
mmx#=(((mx*1.0)/(screen width()*1.0))-0.500)*(camy#*2.0)*(1.10-(((my*1.15)/(screen height()*1.15))-0.575))
mx#=newxvalue(camx#,camera angle y(),0-mmz#)
mz#=newzvalue(camz#,camera angle y(),0-mmz#)
mx#=newxvalue(mx#,wrapvalue(camera angle y()-90),0-mmx#)
mz#=newzvalue(mz#,wrapvalue(camera angle y()-90),0-mmx#)
position object 2,mx#,0,mz#
osx=object screen x(2) : osy=object screen y(2)
`Stand-in cursor
line osx-10,osy,osx+10,osy
line osx,osy-10,osx,osy+10
`Click the mouse to position the box
`NOTE: Everytime you click on the matrice MUSX# etc are set, so you'd do all your mouseclick chores here
if mc=1
mus(mx#,mz#)
position object 3,musx#,musy#,musz#
endif
return
calc_camera:
`Very important, you can't change this without changing the forumulaes - live with it if you can
rotate camera 55,yang,0
mmx=0
mmz=0
msx=mx : if msx<0 then msx=0
msy=my : if msy<0 then msy=0
mox=screen width()-mx : if mox<0 then mox=0
moy=screen height()-my : if moy<0 then moy=0
`Check the edges of the screen and set the values for push scrolling
if msx<50 then mmx=(-50.0+msx)/1.5
if msy<50 then mmz=(-50.0+msy)/1.5
if mox<50 then mmx=(50.0-mox)/1.5
if moy<50 then mmz=(50.0-moy)/1.5
`Calculate the new camera position based on the push scrolling values
camx#=newxvalue(camx#,camera angle y(),0-mmz)
camz#=newzvalue(camz#,camera angle y(),0-mmz)
camx#=newxvalue(camx#,wrapvalue(camera angle y()-90),0-mmx)
camz#=newzvalue(camz#,wrapvalue(camera angle y()-90),0-mmx)
camh#=get ground height(1,camx#,camz#)
if camy#<camh#+50.0 then camy#=camh#+50
position camera camx#,camy#,camz#
return
`This function will return the 3D cursor location based on X, Z, and a height of 0
`It stores the results in MUSX#,MUSY#,MUSZ#
function mus(mx#,mz#)
musx#=mx#
musy#=0
musz#=mz#
position object 2,mx#,0,mz#
point object 2,camera position x(),camera position y(),camera position z()
while object position y(2)<camera position y()
`NOTE - the 25 is for the accuracy, this needs to be as big as you can for speed sakes
`about 1/4 of a tiles width is reasonable, however it can be much less without killing the speed
move object 2,25
mh#=get ground height(1,object position x(2),object position z(2))
if object position y(2)<mh#
musx#=object position x(2)
musy#=object position y(2)
musz#=object position z(2)
endif
endwhile
musy#=get ground height(1,musx#,musz#)
endfunction