Use arrow keys:
sync on : sync rate 60 : autocam off
make object cube 1,10 : color object 1,rgb(255,0,0)
make object collision box 1,-7,-7,-7,7,7,7,0
make object box 2,100,10,10 : color object 2,rgb(0,0,255)
make object collision box 2,-50,-5,-5,50,5,5,0
position object 2,0,0,50
make object box 3,10,10,70 : color object 3,rgb(0,255,0)
make object collision box 3,-5,-5,-35,5,5,35,0
position object 3,30,-2,50
position camera 0,75,-100
pitch camera down 20
s#=1
r#=3
do
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
xa#=object angle x(1)
ya#=object angle y(1)
za#=object angle z(1)
if upkey()
x#=newxvalue(x#,ya#,s#)
z#=newzvalue(z#,ya#,s#)
endif
if downkey()
x#=newxvalue(x#,ya#,-s#)
z#=newzvalue(z#,ya#,-s#)
endif
if leftkey()
ya#=wrapvalue(ya#-r#)
endif
if rightkey()
ya#=wrapvalue(ya#+r#)
endif
position object 1,x#,y#,z#
rotate object 1,xa#,ya#,za#
if object collision(1,0) > 0
x2#=x#-get object collision x()
y2#=y#-get object collision y()
z2#=z#-get object collision z()
position object 1,x2#,y2#,z2#
endif
sync
loop
and here's a very old bit of code that shows you how to do sliding
stuff in a FPS environment.
sync on : sync rate 60 : autocam off
box 0,0,16,16,rgb(255,0,0),rgb(0,0,255),rgb(0,255,0),rgb(0,255,255)
get image 1,0,0,16,16,1
make object cube 1,10
hide object 1
make object collision box 1,-7,-7,-7,7,7,7,0
make object plain 2,300,100
texture object 2,1
scale object texture 2,6,4
make object collision box 2,-150,-50,-1,150,50,1,0
position object 2,0,0,150
make object plain 3,300,100
texture object 3,1
yrotate object 3,90
scale object texture 3,6,4
make object collision box 3,-1,-50,-150,1,50,150,0
position object 3,-150,0,0
make object plain 4,1024,1024
texture object 4,1
xrotate object 4,90
scale object texture 4,16,16
set object collision off 4
position object 4,0,-50,0
make object box 5,20,100,20
color object 5,rgb(0,0,200)
make object collision box 5,-10,-50,-10,10,50,10,0
position object 5,50,0,30
s#=2
r#=3
do
x#=camera position x()
y#=camera position y()
z#=camera position z()
xa#=camera angle x()
ya#=camera angle y()
za#=camera angle z()
if upkey()
x#=newxvalue(x#,ya#,s#)
z#=newzvalue(z#,ya#,s#)
endif
if downkey()
x#=newxvalue(x#,ya#,-s#)
z#=newzvalue(z#,ya#,-s#)
endif
if leftkey()
ya#=wrapvalue(ya#-r#)
endif
if rightkey()
ya#=wrapvalue(ya#+r#)
endif
position camera x#,y#,z#
rotate camera xa#,ya#,za#
position object 1,x#,y#,z#
rotate object 1,xa#,ya#,za#
if object collision(1,0) > 0
x#=x#-get object collision x()
y#=y#-get object collision y()
z#=z#-get object collision z()
position object 1,x#,y#,z#
position camera x#,y#,z#
endif
sync
loop
Be warned though that sliding collision on rotated boxes in DBPro does not work very well, so game will have to be very boxlike.
Boo!