i am making a 2d shoot'em up game. I am stuck on the "shooting bullets" part help would be great. Almost forgot i just want the bullets to go straight right for approx. 600px then "disappear" so i can shoot again
if spacekey() = 1 and firing = 0 then firing =1
if firing = 1 then gosub shoot
shoot:
show sprite 3
rotate sprite 3,90
repeat
move sprite 3,10
Dec bltlife
bltynw = sprite Y(3)
sprite 3,bltxld+0.5,bltynw,3
if bltlife <= 0 then sprite 3,bltxld,bltyld,3
bltlife = 25
firing = 0
return
edit: i got it to shoot but i need help making it so i can shoot again after a certain time
code update.
thanks for the help guys.
sync on
sync rate 30
hide mouse
`man X man Y
mnxld = 0
mnyld =350
`bullet X bullet Y
bltx = mnxld-3
blty = mnyld
`bullet life(can be used to ajust distance bullets fly)
bltlife = 10000
load image ("map1b.png"),1
load image ("knt2_fr1.png"),2
load image ("bullet.png"),3
sprite 1,0,0,1
sprite 2,mnxld,mnyld,2
sprite 3,bltx,blty,3
hide sprite 3
do
sprite 3,bltx,blty,3
hide sprite 3
`firing = 0
if rightkey() = 1 then sprite 2,mnxld+5,mnyld,2:mnxld = sprite x(2)
if leftkey() = 1 then sprite 2,mnxld-5,mnyld,2:mnxld = sprite x(2)
if upkey() = 1 then sprite 2,mnxld,mnyld-3,2:mnyld = sprite y(2)
if downkey() = 1 then sprite 2,mnxld,mnyld+3,2:mnyld = sprite y(2)
if spacekey() = 1 and firing = 0
firing =1
BulletPosX = mnxld + 5
BulletPosY = 350-16
bulletlife = 10
endif
if firing = 1 then gosub shoot
sync
loop
shoot:
show sprite 3
rotate sprite 3,45
Dec BulletPosX,-10
Dec bulletlife,-3
sprite 3,BulletPosX,BulletPosY,3
Sleep 1
sprite 3,BulletPosX,BulletPosY,3
Rem Check to see if we hit anything here and if we did
Rem handle it. Reset flag if bullet is done with
If Bulletlife<=0 Then delete sprite 3
Return