Hello!
I'm trying to make good particle system in 2D game. I loaded sprite for effect to directdraw surface, and I prepared that structure for particle:
struct particle
{
POINT position; //actual position on scree,
bool exist; // does this particle exist in the moment of rendering?
POINT movment; //x, y of translating
short frame; // current frame
int depth; // how far from user particle is
};
And I stored it all in one global array:
I want to blt all of them to the screen, starting from the farest and ending in the closest. Becouse array isn't sorted (To do this, actually I need to sort them in each frame - becouse some particles fading out earlier then others and it doesn't depend on order of creation) I need to make something like that in each frame:
for(int i=FARER_PARTICLE; i<CLOSER_PARTICLE; i++)
{
for(int k=0; k<250; k++)
{
if(flame[k].exist && flame[k].depth==i)
/* Here blt procedure */
}
}
And it works... BUT:
If I have several hundreds of depths multiplays by several hundreds of particles objects - I need to run out about 25 thousands pass in each frames, only for particles!