Hi sta,
I'm not really sure if I'm able to explain this error so you can understand it :sign0013:
This sub is buggy:
Sub CollisionCheck
For a=0 To AlBricksX.Count-1
If rect.X>AlBricksX.Item(a)-15 AND rect.X<AlBricksX.Item(a)+30 AND rect.Y>AlBricksY.Item(a)-15 AND rect.Y<AlBricksY.Item(a)+17 Then
Control("Brick" & a).Dispose
AlBricksY.RemoveAt(a)
AlBricksX.RemoveAt(a)
Speed.Y=-Speed.Y
[COLOR="Red"]Return[/COLOR]
End If
Next
End Sub
If you add the return statement, one of your errors will vanish. This is because you are altering the array within a loop around this array. E.g. AlBricksX.Count = 4 your loop goes from 0 to 3. If a brick is hit, you delete values of each array so only 3 entries are left (from 0 to 2). After that your loop tries to access these arrays with the last value of the loop definition (here 3) but this entry is not available any more.
The second error I came up is because of this:
You added 4 bricks naming brick0, brick1, brick2 and brick3. If the ball hits first e.g. brick2, you dispose brick2 so brick0, brick1 and brick3 are left. Then you remove the position 2 in the x and y array. Now your brick data is messed up! The values AlBricksX.ItemAt(2) and AlBricksY.ItemAt(2) belong to brick3 because the positions in the arrays changed but not the image names.
specci48