// Hilfsfunktion: setzt den Vektor auf zufällige Richtung und Länge
function vec_randomize (var* vec, var 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(PARTICLE *p)
{
p.alpha -= 2*time_step;
if (p.alpha <= 0) p.lifespan = 0;
}
// Partikelfunktion: generiert eine verblassende Explosion in vel-Richtung
function effect_explo(PARTICLE *p)
{
var temp[3];
vec_randomize(temp,10);
vec_add (p.vel_x, temp);
p.alpha = 25 + random(25);
p.bmap = scatter_map;
p.flags |= (BRIGHT | MOVE);
p.event = part_alphafade; // wechsle zu einer kürzeren, schnelleren Funktion
}
...
vec_scale(normal,10); // produziere eine Explosion in Richtung der Normalen
effect(effect_explo,1000,my.x,normal);