Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Removing elements from vector

Name: Anonymous 2011-12-05 9:25

Hi there /prog/

I have a vector that looks like:
<code>
std::vector<Bullet> bullets;
</code>

My bullet struct contains the bullet ID, pixel data, and position.
I set the ID to bullets.size(); on creation.

Whenever a bullet is outside of the camera view, I call: (obviously inside of a loop)
<code>
bullets.erase(bullets.begin() + bullets[bi].ID);
</code>

This works pretty well, unless I spam bullets on the screen.  After a few bullets leave the screen, they all disappear.

What would be the best way to handle cleaning up my bullets?

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-05 10:04

OOP bullets?  SO when you fire a bullet you create an object, with all the properties of the bullet, like speed/weight, which bullet factory and gun was used on it, maximum firing range,etc. You may need an extra layer of OOP handling to safely initiliaze,check and fire each bullet produced by BulletFactory,after awhile you query BULLETSQL databases(optimized for bullets, no bloat), scaling bullet production into extra servers and resynergizing the BulletCloud using latest metatemplates from stackoverflow to produce bullets at ludicrous speed.

Name: Anonymous 2011-12-05 10:07

Read http://gamesfromwithin.com/data-oriented-design and make your own optimized bullet container.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List