int n = (rand() % (100)) < 100; // Get a random number centered on the mean
for (int i = 0; i < n; i++) {
Particle *newParticle = m_particles.NewGeneric<Particle, 16>();
newParticle->m_age = 0.0f;
newParticle->m_life = ((rand() % 100) / 100.0f) + 5.0f;
newParticle->m_texture = m_texture;
newParticle->m_damping = 0.98f;
newParticle->m_scale = 0.0f;
newParticle->m_expansionRate = (rand() % 100) / 100.0f;
newParticle->SetParent(this);
newParticle->m_velocity = ysMath::LoadVector(float((rand() % 200) - 100), float((rand() % 200) - 100), 0.0f);
newParticle->m_position = ysMath::Constants::Zero;
newParticle->m_density = ((rand() % 200 - 100) / 800.0f) + 0.2f;
}
int n = 1;
for (int i = 0; i < 1; i++) {
I don't picture that's what you were after, because you could easily have rewritten that as an if...or just:
Particle *newParticle = m_particles.NewGeneric<Particle, 16>();
newParticle->m_age = 0.0f;
newParticle->m_life = ((rand() % 100) / 100.0f) + 5.0f;
newParticle->m_texture = m_texture;
newParticle->m_damping = 0.98f;
newParticle->m_scale = 0.0f;
newParticle->m_expansionRate = (rand() % 100) / 100.0f;
newParticle->SetParent(this);
newParticle->m_velocity = ysMath::LoadVector(float((rand() % 200) - 100), float((rand() % 200) - 100), 0.0f);
newParticle->m_position = ysMath::Constants::Zero;
newParticle->m_density = ((rand() % 200 - 100) / 800.0f) + 0.2f;
Which I'm guessing is roughly how many particles you wanted to spawn in the timeframe, and that you wanted to try to randomly spawn them at different time frames so each update wouldn't be a continuous stream of new particles?