// Hilfsfunktion: setzt den Vektor auf Zufallsrichtung und -Länge
function vec_randomize(&vec,range)
{
vec[0] = random(1) - 0.5;
vec[1] = random(1) - 0.5;
vec[2] = random(1) - 0.5;
vec_normalize(vec,random(range));
}
// Hilfsfunktion: blendet einen Partikel aus
function part_alphafade()
{
my.alpha -= time+time;
if (my.alpha <= 0) { my.lifespan = 0; } // Alpha <= 0, dann Partikel vernichten
}
//Partikelfunktion: generiert eine verblassende Explosion in Richtung vel
function effect_explo()
{
vec_randomize(temp,10);
vec_add(my.vel_x,temp);
my.alpha = 25 + random(25);
my.bmap = scatter_map;
my.flare = on;
my.bright = on;
my.beam = on; //Partikel verschmieren
my.move = on;
my.function = part_alphafade; // ändere in eine kürzere, schnellerer Funktion
}
...
vec_scale(normal,10); // produziere eine Explosion in Richtung der Normalen
effect(effect_explo,1000,my.x,normal);