You can utilize the formula: speed*time=distance
And solve it for time: Time=distance/speed
You can the set distance to whatever the spacing you want is. Maybe every 8 pixels?
Then you’d have “every 8/speed seconds”
I can see a few issues with that approach though. At low speeds, say 0.1 pixels per second, it will be “every 80 seconds”, or worse still at a speed of zero it will be “every infinity seconds”. You can mitigate it by limiting how big the number can be: min(0.1, 8/speed)
A second issue is the “every x seconds” is any value less than dt will be the same as dt. So at high speeds the tracks would be spaced out more again.
Another idea is to keep track of the previous position of the tank and and use a loop to create tracks between the previous position and the next.
Var prevx=0
Var prevY=0
Var ang=0
Start of layout
— set prevx to sprite.x
— set prevy to sprite.y
Every tick
— set ang angle(prevx,prevy,sprite.x,sprite.y)
Repeat distance(prevx,prevy,sprite.x,sprite.y)/8-1 times
— create track at prevx,prevy
— track: set angle to ang
— add 8*cos(ang) to prevx
— add 8*sin(ang) to prevy