I am also doing this thing, haven't worked out the multiple bulets but what I did was position the bullets where youre camera is e.g. x#,y#,z#
Just look at the code
Rem ++++++++++++++++++++++++++++++++++++++++++++
Rem +++++++++ Star Wars - Hoth wars ++++++++++++
Rem ++++++++++++++++++++++++++++++++++++++++++++
rem Initialisation
sync on
sync rate 30
hide mouse
Set camera range 1,5000
autocam off
Rem star wars theme tune
load music "starwars.mid",1
play music 1
loop music 1
rem Make a terrain to fly over
make matrix 1,10000,10000,50,50
rem texture matrix
load image "grass10.bmp",3
Prepare matrix texture 1,3,2,2
rem tie fighter
load object "tie fighter.x",1
position object 1,100,100,400
rem skysphere
make object sphere 2,10000
load image "test1.bmp",4
set object 2,1,0,0
Texture object 2,4
rem background texture
texture backdrop 4
rem Set up initial positions and angles
x#=5000
y#=200
z#=5000
theta#=0
phi#=0
thruststep#=0.1
rem Set up bullets
dim shot#(10,10)
for i=0 to 9
make object cylinder i+9,5
Rotate object i+9,90,0,0
color object i+9,RGB(20,100,40)
next i
do
rem Mouseclicks control speed
`if mouseclick()=1 then thrust#=thrust#+thruststep#
`if mouseclick()=2 then thrust#=thrust#-thruststep#
rem Now the joystick button controls speed
if joystick fire b()=1 then thrust#=thrust#+thruststep#
if keystate(17)=1 then yaxisstrafe#=yaxisstrafe#-thruststep#
if keystate(30)=1 then xaxisstrafe#=xaxisstrafe#-thruststep#
if keystate(31)=1 then yaxisstrafe#=yaxisstrafe#+thruststep#
if keystate(32)=1 then xaxisstrafe#=xaxisstrafe#+thruststep#
rem Shooting
rem Putting in a firing delay
if joystick fire a()=1 and shotrecently#=0
shotrecently#=4
for i=0 to 9
rem If the bullet is 'dead' then create a new one
if shot#(i,0)=0
rem Alive
shot#(i,0)=1
rem Current position
shot#(i,1)=x#
shot#(i,2)=y#
shot#(i,3)=z#
rem Current velocities plus velocities provided by the gun
shot#(i,4)=xvel#+(sin(theta#)*cos(phi#)*20)
shot#(i,5)=yvel#-(sin(phi#)*20)
shot#(i,6)=zvel#+(cos(theta#)*cos(phi#)*20)
rem Angle
shot#(i,7)=theta#
shot#(i,8)=phi#
rem Life
shot#(i,9)=30
show object i+9
exit
endif
next i
endif
if shotrecently#>0 then shotrecently#=shotrecently#-1
rem Update the bullets
for i=0 to 9
rem If the bullet is 'alive' then move it by it's velocity
if shot#(i,0)=1
shot#(i,1)=shot#(i,1)+shot#(i,4)
shot#(i,2)=shot#(i,2)+shot#(i,5)
shot#(i,3)=shot#(i,3)+shot#(i,6)
position object i+9,shot#(i,1),shot#(i,2),shot#(i,3)
shot#(i,9)=shot#(i,9)-1
rem If it's just run out of 'life' then 'kill' it and make
rem it available for use again
if shot#(i,9)=0
hide object i+9
shot#(i,0)=0
endif
endif
next i
rem Mouse movements control angles
`theta#=wrapvalue(theta#+mousemovex())
`phi#=wrapvalue(phi#+mousemovey())
rem Joystick controls angles
rem Change the value (currently 0.005) to set sensitivity
theta#=wrapvalue(theta#+(joystick x()*0.005))
phi#=wrapvalue(phi#-(joystick y()*0.005))
rem Decay the thrust so you don't go really fast
thrust#=thrust#*0.9
xaxisstrafe#=xaxisstrafe#*0.9
yaxisstrafe#=yaxisstrafe#*0.9
rem Accelerate the velocities (this took ages to work out)
xvel#=xvel#+(sin(theta#)*cos(phi#)*thrust#)
yvel#=yvel#-(sin(phi#)*thrust#)
zvel#=zvel#+(cos(theta#)*cos(phi#)*thrust#)
xvel#=xvel#+(sin(theta#+90)*xaxisstrafe#)
zvel#=zvel#+(cos(theta#+90)*xaxisstrafe#)
xvel#=xvel#+(sin(theta#)*cos(phi#+90)*yaxisstrafe#)
yvel#=yvel#-(sin(phi#+90)*yaxisstrafe#)
zvel#=zvel#+(cos(theta#)*cos(phi#+90)*yaxisstrafe#)
rem Some friction to stop you going too fast
xvel#=xvel#*0.99
yvel#=yvel#*0.99
zvel#=zvel#*0.99
rem Simple velocity
x#=x#+xvel#
y#=y#+yvel#
z#=z#+zvel#
rem Rotate and position the camera
position camera x#,y#,z#
yrotate camera theta#
xrotate camera phi#
rem +++++++++++++++++++++++++++++++++++
Rem this is for the shooting
rem object positions for the shooting
obj1x# = object position x(1)
obj1y# = object position y(1)
obj1z# = object position z(1)
obj3x# = object position x(i)
obj3y# = object position y(i)
obj3z# = object position z(i)
rem distance form bullet and the target
dist# = getdist(obj1x#,obj3x#,obj1y#,obj3y#,obj1z#,obj3z#)
rem kill the enemy when bullet is close to target
if dist#<150
Hide object 1
load sound "explode4.wav",1
play sound 1
endif
rem distance from camera and target
camdist# = getdist(obj1x#,x#,obj1y#,y#,obj1z#,z#)
rem enemy moves if you are close
if camdist#<1000 then move object 1,20
rem ++++++++++++++++++++++++++++++++++++++++
rem position
if camera position x()<0
text 0,0, "you went over the side - are you drunk?"
endif
if camera position y()<0
text 0,15, "what the hell is an X-wing pilot doing drunk?"
endif
if camera position z()<0
text 0,30, "you could only defeat the empire in a drinking contest!"
endif
sync
loop
function getdist(1x#,2x#,1y#,2y#,1z#,2z#)
distance# = SQRT((1x#-x#)^2+(1y#-2y#)^2+(1z#-2z#)^2)
endfunction distance#
hope this works, and posible you could adapt this so that it works for the four bullets