Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Need help with Rapid fire for shoot em up!!!

Author
Message
TLOZ
21
Years of Service
User Offline
Joined: 7th May 2005
Location: Enfield, NC
Posted: 8th May 2005 12:50
Ive had DB for about a year and I just can't get this rapid fire thing down. Im making a 2D side scrolling shooter. When I press the fire key, all of my bullets come out at the same time instead of one after another. Can anyone show me how to fix this!!!
TLOZ
21
Years of Service
User Offline
Joined: 7th May 2005
Location: Enfield, NC
Posted: 9th May 2005 13:29
Ive had DB for about a year and I just can't get this rapid fire thing down. Im making a 2D side scrolling shooter. When I press the fire key, all of my bullets come out at the same time instead of one after another. Can anyone show me how to fix this!!!

this is the code Ive been using from the forums.

`variables
dim btime(10)
dim bx(10)
dim by(10)

`Check and reset bullets
if spacekey()=1
for a = 1 to 10
if btime(a) = 0
btime(a) = 120
`x(1) and y(1) are the player's position.
bx(a) = x(1)
by(a) = y(1)
endif
next a
endif

`move bullets
for a = 1 to 10
if btime(a) > 0
btime(a) = btime(a) - 2
bx(a) = bx(a) + 25
endif
`position bullets
sprite a,bx(a),by(a),100
next a
TLOZ
21
Years of Service
User Offline
Joined: 7th May 2005
Location: Enfield, NC
Posted: 9th May 2005 14:02
Don't worry about my question, I just figured out the problem.
UnderLord
22
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 10th May 2005 16:06
lol nice =) good luck buddie....do you mind if i use this code in the next 2d tutorial i do? i seem to have problems with shooting and uhh everything inbetween.

Of coures you'll get credit for the code...see my tutorial in Another tutorial in this forum (2d all the way)

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
Schizophrenic beats eating alone.
TLOZ
21
Years of Service
User Offline
Joined: 7th May 2005
Location: Enfield, NC
Posted: 10th May 2005 20:20
sure! I don't mine. I learned the code from somebody else, so go ahead and use it as you want. If that code doesn't work, then try using this one. This is the code I came up with. Good Luck!

`create variables
dim x(1)
dim y(1)
dim bullets(10)
dim btimer(1)
dim bxmove(1)
dim xpos(10)
dim ypos(10)

`setup up what their values are
for b = 2 to 10
bullets(b) = 0
next b
btimer(1) = 100
bxmove(1) = 2

`check bullets and reset bullets
if spacekey()=1
btimer(1) = btimer(1) - 1
for a = 2 to bxmove(1)
if bullets(a)=0
hide sprite a
bullets(a)=120
xpos(a) = x(1)
ypos(a) = y(1)
endif
next a
endif

`bxmove timer, this spreads out the bullets
if btimer(1) < 100 and btimer(1) > 90 then bxmove(1) = 2
if btimer(1) < 90 and btimer(1) > 80 then bxmove(1) = 3
if btimer(1) < 80 and btimer(1) > 70 then bxmove(1) = 4
if btimer(1) < 70 and btimer(1) > 60 then bxmove(1) = 5
if btimer(1) < 60 and btimer(1) > 50 then bxmove(1) = 6
if btimer(1) < 50 and btimer(1) > 40 then bxmove(1) = 7
if btimer(1) < 40 and btimer(1) > 30 then bxmove(1) = 8
if btimer(1) < 30 and btimer(1) > 20 then bxmove(1) = 9
if btimer(1) < 20 and btimer(1) > 10 then bxmove(1) = 10
if btimer(1) < 10
bxmove(1) = 2
btimer(1) = 100
endif

`resets the btimer
if spacekey()=0 then btimer(1) = 99

`moves the bullets across the screen
for b = 2 to 10
if bullets(b) > 0
show sprite b
bullets(b) = bullets(b) - 4
xpos(b) = xpos(b) + 30
endif
sprite b,xpos(b),ypos(b),100
next b

Login to post a reply

Server time is: 2026-06-12 13:03:16
Your offset time is: 2026-06-12 13:03:16