Sign in to follow this  
MrPickle

Particle Problem

Recommended Posts

I have made a simple particle class but I have a problem, all the particles are being created at the same time. So it just looks like a single particle. I don't know how to combat this? Here's my current code:
if(particles.size() < density)
	{
		for(unsigned int i = 0; i < density - particles.size(); i++)
		{
			particle_obj po;
			po.position = start;
			po.life = 0;
			po.local_x = 0;
			particles.push_back(po);
		}
	}

Share this post


Link to post
Share on other sites
You have to spread the creation of particles over many frames to achieve the effect you're looking for. What you have now creates a bunch of particles during a single frame, and the resulting mess is going to look like a single particle with much worse performance [smile]

Share this post


Link to post
Share on other sites
I tried limiting the amount of particles it can create per frame by adding:

if(i > 10)
{
break;
}




But now I am only getting 11 particles, without this I am getting 33 particles instead of 100.

All is fixed (:
The function has a variable for the amount of milliseconds past since the last frame to the function but I was passing the amount of milliseconds passed since the program started instead which meant that the particles were being destroyed as soon as they were created.

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this