var culling_distance = 4000;
action NULL_()
{
while(me)
{
if (vec_dist (my.x, camera.x) < culling_distance) // the player has come close to this entity?
{
reset(my, INVISIBLE); // then show it!
while (my.alpha < 100) // run this loop until the entity becomes opaque again
{
my.alpha = minv(100, my.alpha + 15 * time_step); // increase my.alpha (15 = speed) and limit it to 100
wait (1);
}
reset(my, TRANSLUCENT); // get rid of some nasty artifacts when the entity is completely visible
}
else // the player has moved away from this entity?
{
set(my, TRANSLUCENT); // then set the "transparent" flag again
while (my.alpha > 0) // run this loop until the entity becomes practically invisible (alpha = 0)
{
my.alpha = maxv(0, my.alpha - 15 * time_step); // decrease my.alpha (15 = speed) and limit it to 0
wait (1);
}
set(my, INVISIBLE); // now hide the entity in order to increase the frame rate
}
wait(1);
}
}