![]() |
|
Fire
Let's continue with the particle
function.
The movement on the z-axis can be a slow, steady
upward movement. my_speed.z = 0.7 + random(0.4); Since this value is only assigned at the particle initialisation, it remains constant for the lifetime of it's 'mother-particle'.
The movement of the particles on the
other two axes is more complicated. We want
to simulate a natural, flowing movement, so using Sinus and Cosinus
functions is a good solution.
But we need some randomness here too, otherwise
our particles would allways change their directions together (they
would always have the same x and y speeds) which would lead to an easily
spottable movement pattern.
my_color.red = random(150); We can also incorporate some randomness into the particle size assignment: my_size = 700 + random(300); We also set the 'my_flare' and 'my_bright' flags to ON, since we want our particles to use the alpha map and to be 'glowing'. We use my_flare instead of my_transparent, because my_transparent can sometimes cause the alpha channel to remain unused on some video cards (riva tnt2 for example - this leads to blocky quadratic particles that ruin the effect). This problem only occurs randomly, but we can totally rule it out by using my_flare instead of my_transparent. The particles are killed at an age of 30:
if (my_age >
30) { |