Game Development Reference
In-Depth Information
(it's actually the initial velocity of the particles)
life: life of the particles in milliseconds; particles will
fade and die out as they approach
their specified life
gravity: the acceleration due to gravity, which controls the
rate at which particles will fall
as they fly
angle: initial trajectory angle of the particles,
specify 999 to create a particle explosion
that emits particles in all directions; otherwise,
0 right, 90 up, 180 left, etc...
*/
void CreateParticleExplosion(int x, int y, int Vinit, int life,
float gravity, float angle)
{
int i;
int m;
float f;
Explosion.Active = TRUE;
Explosion.x = x;
Explosion.y = y;
Explosion.V0 = Vinit;
for(i=0; i<_MAXPARTICLES; i++)
{
Explosion.p[i].x = 0;
Explosion.p[i].y = 0;
Explosion.p[i].vi = tb_Rnd(Vinit/2, Vinit);
if(angle < 999)
{
if(tb_Rnd(0,1) == 0)
m = −1;
else
m = 1;
Explosion.p[i].angle = -angle + m * tb_Rnd(0,10);
} else
Explosion.p[i].angle = tb_Rnd(0,360);
f = (float) tb_Rnd(80, 100) / 100.0f;
Explosion.p[i].life = tb_Round(life * f);
Explosion.p[i].r = 255;//tb_Rnd(225, 255);
Explosion.p[i].g = 255;//tb_Rnd(85, 115);
Explosion.p[i].b = 255;//tb_Rnd(15, 45);
Explosion.p[i].time = 0;
Explosion.p[i].Active = TRUE;
Explosion.p[i].gravity = gravity;
}
}
Search Nedrilad ::




Custom Search