In several paragraphs :
Basically what you want to do is make it so that when your guy fires his weapon, he creates a new sprite for the ammo and attaches it to a bullet linked list of his. This allows you to have as many bullets as you want on screen at once.
An optimization can be made : instead of new and deleteing the sprite headers, have a seperate linked list of free bullets. On starting the game, "new" and place into the list a reasonable number of bullet sprite structures. Then, when your guy needs to shoot his weapon, you simply retrieve&remove from the free list and add it to his own list. When the bullet expires, you remove it from his list and add it to the free list. This removes all the memory-management overhead that new and delete would impose. And since adding a element (and removing a node if you already are at that element) in a list is a constant-time operation, your list management imposes no performance hit. Not too big a deal for small numbers, but if you have hundreds or more of bullets flying around, its a big deal. If you go to fire a weapon and the free bullet list is empty, then -- and only then -- do you go ahead and "new" a new sprite header. When its done, it will then go back into the free bullet pool, so that the list will expand depending on what the max bullets is you've been using so far this game session.
------------------
- Remnant
- (Steve Schmitt)