Sidenote:
Why save the positions of the float when you can just move the balls 1 position. If the vector is 0.2 you can just move it 1. The vector is a value of -1..1 so it should move -1, 0 or 1. You don't need to store the float.
So I did this and it worked:
if abs(vv) > 0 then // when the distance of connect points is > 0
begin
ball[i + 1].left := ball[i + 1].left + sign(uxx) * ceil(abs(uxx));
ball[i + 1].top := ball[i + 1].top + sign(uyy) * ceil(abs(uyy));
end;
(Is there a round up which rounds down when negative? I used sign(x) * ceil(abs(x)) now but is there a single function for this?)
Next you need to use the connection points to move the follow-balls. And you need to keep moving them until they are connected on THAT connection point. Not on any other point.
So you need to use direction of the main ball to determine the connection point.
I used this:
//to get vectors
// vxx := (ball[i].left - 15) - (ball[i + 1].left - 15);
// vyy := (ball[i].top - 15) - (ball[i + 1].top - 15);
case direction of
0: continue; // only start moving when main ball starts
1:
begin // dir=left, connect right.x middle.y with with followballs left.x middle.y
vxx := (ball[i].left + 30) - (ball[i + 1].left);
vyy := (ball[i].top + 15) - (ball[i + 1].top + 15);
end;
2:
begin // dir=right, connect left.x middle.y with followballs right.x middle.y
vxx := (ball[i].left) - (ball[i + 1].left + 30);
vyy := (ball[i].top + 15) - (ball[i + 1].top + 15);
end;
3:
begin // dir=up, connect middle.x bottom.y with followballs middle.x top.y
vxx := (ball[i].left + 15) - (ball[i + 1].left + 15);
vyy := (ball[i].top + 30) - (ball[i + 1].top);
end;
4:
begin // dir=down, connect middle.x top.y with followballs middle.x bottom.y
vxx := (ball[i].left + 15) - (ball[i + 1].left + 15);
vyy := (ball[i].top) - (ball[i + 1].top + 30);
end;
end;
After that vv should be in the range of -1..1 in distance to the real connect points. So move the balls when " if abs(vv) > 0 then ".
This all worked fine for me and there is no need to save the fraction of vv because that would make the follow-balls go slower.