# How to leave trails that are equidistant apart from each other

I want bunch of circles to follow the player while keeping a distance apart. So far I have this:

local p = {
x=0,
y=0,
life={
{x=0,y=0},
{x=0,y=0},
{x=0,y=0},
{x=0,y=0}
}
}

local last={x=p.x,y=p.y}
for l in all(p.life) do
l.x = lerp(last.x,l.x,0.5)
l.y = lerp(last.y,l.y,0.5)
circfill(l.x,l.y,2,7)
last={x=l.x,y=l.y}
end


But this makes it so the circles collapse into each other and the player. I want the circles to have a distance between themselves and the player.

I've also tried this:

  l.x = lerp(last.x*0.8,l.x,0.5)


This leaves a distance as I want but the trail is always on the upper left, barely following player.

I want the trail to stay always behind the player.

Probably I can achieve this by stop following if the distance is less than threshold.

if vdist(last,l) < 10 then