It took me roughly 15 hours of experimentation to figure this out
and I didn't copy this from someone else. The reason is I suck at reading other peoples code so I decided to just go into it blindly
until I either succeeded or died trying, luckily I succeeded!
The hardest part was trying to detect collision with a 3D object, and not to mention programming total freedom of movement for the 3D object.
Well here it is my very first 3D program! Use the arrow keys to move the cube around. After you are done hit the ESC button to exit the program!
REM Project: FPS Shooter
REM Created: 7/2/2008 9:20:49 PM
REM
REM ***** Main Source File *****
REM
autocam off
sync on
sync rate 60
gosub makeroom
gosub camera
gosub makecube
`main loop
do
movecube()
sync
set cursor 0,0
print "pos x: ", x
print "pos y: ", y
print "pos z: ", z
loop
makeroom:
`make player room
make object plain 1,200,200
rotate object 1,90,0,0
load image "grass.bmp",1
texture object 1,1
return
camera:
make camera 1
position camera 1,200,50,0
point camera 1,0,0,0
return
makecube:
make object cube 2,20
position object 2,0,10,0
rotate object 2,0,90,0
`set object rotation xyz 2
return
function movecube()
x=int(object position x(2))
y=int(object position y(2))
z=int(object position z(2))
if leftkey()=1
rotate object 2,0,object angle y(2) + -2,0
endif
if rightkey()=1
rotate object 2,0,object angle y(2) - -2,0
endif
if upkey()=1
move object 2,-2
else if downkey()=1
move object 2,2
endif
endif
if x > 89
x=x-2
position object 2,x,y,z
endif
if x < -89
x=x+2
position object 2,x,y,z
endif
if z > 89
z=z-2
position object 2,x,y,z
endif
if z < -89
z=z+2
position object 2,x,y,z
endif
endfunction