Hi,
I'm attempting to make an old school space shooter and I had a question about making a 'Rapid Fire' stream of bullets. This will be a top down shooter and my problem is, when the player sprite is moving up and down in 'Y', my stream of bullets will tend to compress or expand as the ship moves. I have looked at a few space shooters, and I think the bullets are moving with the ship, in 'Y'.
At any rate, I don't really notice this problem on real arcade games. It always looks like a solid stream of bullets. I have tried adding the value that the player's ship moves to the 'Y' value of the bullets, but I can't make it work properly. Here is some code on how I'm doing it now. Maybe I'm doing this wrong. Let me know what you guys think. Thanks.
letter$ = "M"
text 0,0,letter$
get image 1,0,0,8,15,1
box 0,0,10,10
get image 2,0,0,10,10,1
cls
dim sx(12)
dim sy(12)
x = 320
y = 240
a = 2
time = timer()
backdrop off
hide mouse
flush video memory
sync on
sync rate 85
repeat
sprite 1,x,y,1
rem check if arrow keys are pressed for player movement
if keystate(203) then inc x,-5
if x < 0 then x = 0
if keystate(205) then inc x,5
if x > 632 then x = 632
if keystate(200) then inc y,-5
if y < 0 then y = 0
if keystate(208) then inc y,5
if y > 468 then y = 468
rem check if left control key is pressed, and if so, wait for timer, then get bullet position
if keystate(29)
if timer() > time + 50
gosub bullet_position
endif
endif
rem move all bullets and delete them once they are beyond limit
for z = 2 to 12
inc sy(z),-10
sprite z,sx(z),sy(z),2
if sy(z) < -10 then delete sprite z
next z
rem display some helpful info for me :)
text 0,0,"Frames Per Second "+str$(screen fps())
text 0,20,"Bullet Sprite "+str$(a)
text 0,30,"Bullet X Position "+str$(sx(a))
text 0,40,"Bullet Y Position "+str$(sy(a))
text 0,50,"Time Between Bullets "+str$(timer()-time)
sync
until scancode() = 1
rem bullet_position gets position of each bullet and puts it into an array for x and y position
rem if we reach the max our array can handle then start it over at 2 again.
bullet_position:
inc a,1
if a = 12 then a = 2
sx(a) = sprite x(1)
sy(a) = sprite y(1)
time = timer()
return