function p_alphafade(PARTICLE *p)
{
p.alpha -= p.skill_a*time_step;
if (p.alpha <= 0) p.lifespan = 0;
}
function p_trace(PARTICLE *p)
{
set(p, BRIGHT|TRANSLUCENT|BEAM);
p.size = 2;
p.skill_a = 1; // fade factor
p.event = p_alphafade;
}
// entity that runs in circles and leaves a vapor trail
action tracer()
{
var dist = 0,radius = 10,sign = 1;
VECTOR last_pos;
while(1)
{
vec_set(last_pos,my.x);
dist += 30*time_step;
radius += sign*random(3)*time_step; // change radius randomly
if (radius > 150) sign = -1;
else if (radius < 30) sign = 1;
my.x = radius*sin(dist);
my.y = radius*cos(dist);
effect(p_trace,1,my.x,vec_sub(last_pos,my.x));
wait(1);
}
}
function main()
{
vec_set(sky_color,vector(50,1,1)); // dark blue
level_load(NULL);
video_window(NULL,NULL,0,"Vapor trail demo");
vec_set(camera.x,vector(-250,0,50));
vec_set(camera.pan,vector(0,-15,0));
ent_create(NULL,vector(0,0,0),tracer);
}