Quote Originally Posted by User137
On second thought the previous while loop must've been ok too...

But i'd do with for loop, optimizing list deletion faster same time:

[pascal]for i:=clouds.count-1 downto 0 do
begin
tmpcloud := TCloud(clouds[i]);
tmpcloud.x := tmpcloud.x-tmpcloud.speed;

if(tmpcloud.img=0) then
begin
locallist.Find('cloud1').DrawAlpha(AdDraw,AdRect(t mpcloud.x,
tmpcloud.y,tmpcloud.x+151,tmpcloud.y+77),0,150);
end else
begin
locallist.Find('cloud2').DrawAlpha(AdDraw,AdRect(t mpcloud.x,
tmpcloud.y,tmpcloud.x+183,tmpcloud.y+79),0,150);
end;
if(tmpcloud.x <= -185) then { Actual Deletion Here }
begin
TCloud(clouds[i]).Free;
clouds[i]:=clouds[clouds.Count-1];
clouds.delete(clouds.Count-1); // deleting last index prevents
// moving of all last clouds in the array forward
// but it changes drawing order which isn't usually a problem
end;
end;[/pascal]
I thought I read somewhere that for loops were less efficient than while loops, which is why I've been using them. I'll try the optimized deletion later today.