Feuer

My_alpha is altered according to the particle age. But this time, a simple fade-out is not enough, we also have to fade the particles in when they are young. Otherwise a 'popping into sight' effect would occur at the bottom edge of the fire. If the particles are older as 7, they are smoothly faded out, otherwise ( '} else {' ) they are faded in.

if (my_age > 7) {
    my_alpha = 91 - my_age * 3;
} else {
    my_alpha = my_age * 10;
}

That's it! Our fire effect is ready to burn!
  
You can find the tutorial-templates for this chapter ( 'tut4.wdl' and 'tut4.wmp') in the usual folder.

Have fun testing different Skill8 (emitter object) values,
they can drastically change the look of the effect.
Common values range from 1 to 5.

Here is the complete particle-function code:

function test_particle1(){
    if (my_age == 0) {                                               // particle initialisation
        my_alpha = 0;
        my_speed.z = 0.7 + random(0.4);                    // set speed.z
        my_color.red = random(150);                           // random offset for sinus funct.
        my_color.green = random(150);                       // random offset for cos funct.
        my_size = 700 + random(300);                        // set size
        my_map = fire_map;                                       // set bitmap
        my_flare = ON;                                              // transparent
        my_bright= ON;                                             // glowing effect
        END;
    }
    if (my_age > 30) {                                              // kill particle at the age of 30
        MY_ACTION = NULL;
   }
    if (my_age > 7) {                                                // alpha depending on age
        my_alpha = 91 - my_age * 3;
    } else { my_alpha = my_age * 10; }
    my_speed.x = sin (my_age * 7 + my_color.red) / 7;        // speed.x - variation
    my_speed.y = cos (my_age * 8 + my_color.green) / 7;   // speed.y - variation
}