Here you go.
`standard initialisation
autocam off
sync on
sync rate 60
hide mouse
sync
`make the gun, put it in the right place then lock it to the screen.
make object cylinder 100,20
scale object 100,50,50,200
xrotate object 100,90:fix object pivot 100
position object 100,camera position x()+20,camera position y()-20,camera position z()+40
yrotate object 100,wrapvalue(camera angle y())
lock object on 100
`make the bullets
for i=1 to 10
make object sphere i,5
hide object i
next i
dim bullets(10)
height=100
make matrix 1,1000,1000,5,5
do
`mouselook commands
dx#=dx#+mousemovey()/4
cy#=wrapvalue(cy#+mousemovex()/4)
if dx#>90 then dx#=90
if dx#<-90 then dx#=-90
cx#=wrapvalue(dx#)
rotate camera cx#,cy#,cz#
oldx#=x#
oldz#=z#
`arrowkey control
if upkey()=1 then x#=x#+sin(cy#)*15
if upkey()=1 then z#=z#+cos(cy#)*15
if downkey()=1 then x#=x#+sin(cy#+180)*10
if downkey()=1 then z#=z#+cos(cy#+180)*10
if leftkey()=1 then x#=x#+sin(cy#-90)*10
if leftkey()=1 then z#=z#+cos(cy#-90)*10
if rightkey()=1 then x#=x#+sin(cy#+90)*10
if rightkey()=1 then z#=z#+cos(cy#+90)*10
`if there's a 'dead' bullet then put it in the gun, point it in the right direction and make it 'alive'
if spacekey()=1 and fired=0
fired=1
for i=0 to 9
if bullets(i)=0
bullets(i)=100
show object i+1
`these angles and positions don't work for some reason
position object i+1,camera position x()+20,camera position y()-20,camera position z()+40
rotate object i+1,camera angle x(),camera angle y(),camera angle z()
`this is messy, you could probably put it in a subroutine
goto 10
endif
next i
endif
10:
`to stop you holding down space and getting a clump of bullets
if spacekey()=0 then fired=0
`if the bullets are 'alive' then move them, if they have just 'died' then hide them, decrease their 'life'
for i=0 to 9
if bullets(i) > 0
bullets(i)=bullets(i)-1
move object i+1,20
if bullets(i)=0
hide object i+1
endif
endif
next i
`collision code
if get static collision hit(oldx#-20,oldy#-20,oldz#-20,oldx#+20,oldy#+20,oldz#+20,x#-20,y#-20,z#-20,x#+20,y#+20,z#+20)=1
dec x#,get static collision x()
dec y#,get static collision y()
dec z#,get static collision z()
endif
y#=get ground height(1,x#,z#)
position camera x#,y#+height,z#
`crosshair
ink rgb(255,0,0),0
line 320,230,320,250
line 310,240,330,240
circle 320,240,7
set cursor 1,1
print screen fps()
sync
loop