# Help with looping images

Hi guys my code for collision detection is as follows i need it to loop through 55 pictures on the main form //aliens are named alien1, alien2 ect //image2 is the collison object ( the bullet)

CODE IS TURBO DELPHI

``````procedure TForm1.TimeralienshotTimer(Sender: TObject)
var
ax2 : integer;
bx2 : integer;
ay2 : integer;
by2 : integer;
alienX : array[1..55] of integer;
alienY : array[1..55] of integer;
Index: Integer;
begin
for index := 1 to 55 do
alienX[index]:= alien([index]).left <--- the problem is this code here !!!!
ax2 := alienX + 21;
bx2 := Image2.left + 10;
ay2 := AlienY + 25;
by2 := Image2.top + 24;
if ax2 >= alienX then
if alienX <= bx2 then
if ay2 >= image2.top then
if alienY <= by2 then
begin
alien[index].Visible := false;
Image2.top := 875;
Image2.left := 648;
Timershotmovment.Enabled := false;
end;
end;
```
```

``````for index := 1 to 55 do
alienX[index]:= alien([index]).left <--- the problem is this code here !!!!
```
```

Two things:

1. "The problem is this code here" - What problem? You didn't mention one, either in the subject or the question itself.

2. The typecast you're trying to make where the "problem" apparently occurs can't possibly work. You can't typecast an integer array index as a type alien (which doesn't exist anywhere in your code, btw - you've declared two integer arrays named alienX and alienY, but nothing declared as simply alien).

If your intent was simply to copy alienY's content into the alienX array, you can use this:

``````for i := 1 to 55 do
alienX[i] := alienY[i];
```
```

Or, better yet in case the limits of the arrays need to change in the future:

``````for i := Low(alienX) to High(alienX) do
alienX[i] := alienY[i];
```
```

However, since you're trying to access something with a "left" property, that's probably not what you intend. However, without knowing what "alien" is exactly, and what it contains, it's hard to be more specific.

A suggestion for the future? When you say you have a "problem", it helps if you tell people what "problem" is exactly.