OK here is the code that makes your game shoot and detect when a player has been hit (kind of, it doesnt work that well)...
Sync On
Sync Rate 30
Hide mouse
Backdrop on
Set camera range 1,5000
Fog off
Fog distance 1500
Fog color RGB(128,128,128)
Color Backdrop RGB(128,128,128)
Rem make matrix
Make matrix 1,5000,5000,20,20
Rem texture matrix
Load image "grass.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
rem hide mouse
hide mouse
rem Make Gun
Make object cylinder 1,2
XRotate Object 1,90
Fix object pivot 1
Scale object 1,100,100,500
position object 1,0,-7,12
Lock object on 1
Rem Make bullet
Make Object Sphere 2,2
Hide Object 2
rem ppl in level
LOAD OBJECT "idle.x",5 : APPEND OBJECT "walk.x",5,100
YROTATE OBJECT 5,180 : FIX OBJECT PIVOT 5
mx#=1020
my#=1
mz#=2000
position object 5,mx#,my#,mz#
LOOP OBJECT 5,0,20 : set object speed 5,15
object5life=50
do
Rem check for key presses and control movement
Rem forward and backward movement
if upkey()=1 then x#=newxvalue(x#,a#,20):z#=newzvalue(z#,a#,20)
if downkey()=1 then x#=newxvalue(x#,a#,-20):z#=newzvalue(z#,a#,-20)
Rem sidesteps
if leftkey()=1 then x#=newxvalue(x#,wrapvalue(a#-90),20):z#=newzvalue(z#,wrapvalue(a#-90),20)
if rightkey()=1 then x#=newxvalue(x#,wrapvalue(a#+90),20):z#=newzvalue(z#,wrapvalue(a#+90),20)
Rem turning and camera movement using mouse
a#=wrapvalue(a#+mousemovex()/4)
a2#=wrapvalue(a2#+mousemovey()/4)
Rem limit vertical camera movement
if a2#>=60 and a2#<100 then a2#=60
if a2#<=300 and a2#>200 then a2#=300
Rem find ground height and position camera relative to it
y#=get ground height(1,x#,z#)+150
Rem position camera
position camera x#,y#,z#
yrotate camera a#
xrotate camera a2#
Rem detect for bullet firing
if mouseclick()=1 and bulletlife=0
show object 2
Rem position bullet using triganometry
bx#=x#+sin(a2#)*sin(a#)*-7
by#=y#+cos(a2#)*-7
bz#=z#+sin(a2#)*cos(a#)*-7
position object 2,bx#,by#,bz#
set object to camera orientation 2
bulletlife=25
endif
Rem move bullet if bulletlife is more than 0
if bulletlife>0
move object 2,10
dec bulletlife
bx#=object position x(2)
by#=object position y(2)
bz#=object position z(2)
else
hide object 2
endif
Rem calculate how far away bullet is from man and if it is close enough then type "HIT!!!"
if sqrt((mx#-bx#)^2+(my#+75-by#)^2+(mz#-bz#)^2)<100 and bulletlife<>0
text 20,20,"HIT!!!"
bulletlife=0
endif
Rem update screen and loop
sync
loop
Its probably also very messy, tidy it up if you want and post back if you dont understand anything.]
Hamish
Yum! Yum! Yum! Yum!