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.

Newcomers DBPro Corner / fireing multiple bullets

Author
Message
Bishop
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: In my favorite chair...
Posted: 27th Aug 2003 08:48
how do you fire multiple bullets? i know how to fire one at a time, but not multiple...thanx

"When you were born, you cried and the world rejoiced. Live so when you die, the world cries and you rejoice."
o0 Static 0o
21
Years of Service
User Offline
Joined: 27th Aug 2003
Location: Belgium
Posted: 27th Aug 2003 12:14
i gote the same problem
adr2
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 27th Aug 2003 17:43 Edited at: 27th Aug 2003 17:45
disclaimer: I'm at work, so I can't check my syntax

If you set a maximum number of bullets on screen at one given time, it's made a whole lot easier.

Let's say you're going to allow 100 bullets on screen at one time - declare the following globally (for the moment):


then everyTime you fire, set the bulletCounter'th entry in the bulletAge array to 0. As each bullet flies, increment it's age. If its age breaches a threshold, set it's age to -1. Use a bullet's age to determine whether it should be drawn ... Here's some pseudocode..

dragon tail
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location: United Kingdom
Posted: 27th Aug 2003 21:15
@ adr2
good code, i never thought of that

@ Bishop
i had the same problem, so i tried doing this:

i created 30 bullets using the For Loop. i gave each bullet a set amount of "energy". once the bullet had been fired from the gun then i would decrease the energy of the bullet by 1 per loop untilled it died or hit a object.

say the energy was 40 for each bullet. once the energy of the first bullet was at 38, i would fire the second bullet. once the energy of the second bullet was 38 i would fire the thrid...and so on. this is more complicated than adr2's code but i found it worked for me and thats the main thing

Login to post a reply

Server time is: 2024-09-20 21:37:37
Your offset time is: 2024-09-20 21:37:37