sync rate 0
sync on
cls rgb(200,0,0)
line 10,10,5,0
line 0,10,5,0
get image 1,0,0,10,10
cls rgb(0,200,0) : get image 2,0,0,5,10
`load image "images/defiant.bmp",1
`load image "images/bg16.bmp",100 : sprite 100,0,0,100 : size sprite 100,640,480
rem setup player sprite
sprite 1,320,240,1
rem Max bullet life
MaxLife = 100
MaxNumOfBullets=200
Dim Bullets(maxnumofbullets,2)
BulletWait = 100 : `Number of milliseconds between each bullet
X = 320
Y = 240
Ang=0
Velocity# = 0.0
rem main loop
do
goSub ControlPlayer
goSub BoundPlayer
goSub Bullets
ink 0,0
box 0,0,640,480
ink rgb(255,255,255),0
set cursor 10,10
PRINT "FPS: ";screen fps()
print bullets
print velocity#
sync
loop
BoundPlayer:
if sprite x(1) < 0 then sprite 1,0,sprite y(1),1
if sprite y(1) < 0 then sprite 1,sprite x(1),0,1
if sprite x(1) > 640 then sprite 1,640,sprite y(1),1
if sprite y(1) > 480 then sprite 1,sprite x(1),480,1
return
ControlPlayer:
rem sprite x and y
spaceshipx = SPRITE X(1)
spaceshipy = SPRITE Y(1)
s_centre_x = (sprite width(1)/2)+spaceshipx
s_centre_y = (sprite height(1)/2)+spaceshipy
rem player movement
if upkey()=1 then inc Velocity#,0.2
if downkey()=1 then dec Velocity#,0.2
if leftkey()=1 then dec Ang,3
if rightkey()=1 then inc Ang,3
Move sprite 1,Velocity#
if upkey()=0 and downkey()=0 and velocity# <> 0
if velocity# > 0 then dec velocity#
if velocity# < 0 then inc velocity#
velocity# = 0
endif
if velocity# > 2 then velocity# = 2.0
if velocity# < -2 then velocity# = -2.0
Rotate sprite 1,curveangle(Ang,sprite angle(1),30)
return
Bullets:
rem Loop through each bullet "slot"
for b = 1 to MaxNumOfBullets
rem Fire Sprite
if controlkey()=1 and Bullets(b,1)=0 and (timer()-LastCreated) > BulletWait
sprite b+10, s_centre_x, s_centre_y, 2
rotate sprite b+10,sprite angle(1)
Bullets(b,1)=1
Bullets(b,2)=0
show sprite b+10
move sprite b+10,3
rem Store time when bullet was last created, to allow a few secs between each create
LastCreated = timer()
endif
rem If fired, move
if Bullets(b,1)=1
move sprite b+10,6
`DBP bug - cannot decrement arrays
l = bullets(b,2)
inc l
Bullets(b,2) = l
endif
rem Stop if at end of life and decrement bullets
if Bullets(b,2) > maxlife
Bullets(b,1)=0
hide sprite b+10
endif
next b
return
Maybe this will help. It's a 2d rapid fire snippet I wrote a while back. It's pretty easy to covert to 3D. I use it for Mercenaries 2.

Merry Christmas to all Apollo members!
Visit [url]www.lightning-systems.co.uk[/url] :: [url]www.realgametools.net/forums[/url]