Okay... I'm working on my bullet system a little, part of my optimization phase, and I was wondering if anyone had input on the way I'm handling them.
Here's a rundown of the current system:
Each individual enemy, and the player ship, has an AmmoController object. AmmoController objects maintain a linked list of Ammo objects currently fired from the object firing them.
Ammo objects contain information about the mesh used for the projectile: its mesh [stored in an AmmoMesh object, just a basic wrapper for DX's Mesh class], its firing type, and if applicable, its wave type.
Firing type defines just how the bullet fires, whether it's straight, angled [including 360 degree fire around the ship firing], spiraling, or in a wave. I plan on adding more, but I wanted to implement these basics for now.
Wave type determines, for wave type bullets, what the waveform is. Currently I implement Cosine, Sine, and inverses of both.
So when I instantiate a bullet in a ship.fire() call, I create a new Ammo object and pass it the required params, then store it in the controller. This ammo object represents one bullet in the world.
When it comes time to render, I run through the world's enemy controller [a linked list of enemies currently active in the world], and call each enemy's render function. In that function I call the enemy's AmmoController render function, which itself loops through all ammo objects owned by the enemy and renders / moves them based on their firing type, wave type, etc. I do the same for my player ship's ammo controller.
It seems like this way works well, and it's really quite easy to use - just define a bullet, add it to the controller, and everything takes care of itself. I think I've had about 500-700 bullets active on the screen [angled ones, they require extra horsepower due to more involved translation of the meshes] before I got a noticable drop in fps. This is just me turning the refire rate on the player ship waaaay higher than it'll end up being by default, to try to stress-test the engine.
Bullet handling... advice?
-
sniperwolf
- Posts: 39
- Joined: Wed Aug 10, 2005 10:44 pm
- Location: Oregon
Bullet handling... advice?
How do I wrote code?