Exclude objects from For Next loop

BlitzMax Forums/BlitzMax Beginners Area/Exclude objects from For Next loop

Hi,
let's say I want to check each variable inside an array of an object with each variable of the array in each other object . After looping through all the variables of object A, it has to be blocked from the list so that the loop does not produce equal AB / BA pairs NOR does it allow object A to be compared with any other object during that frame.
It's basically an intersecting lines detection, where the lines are "reconstructed" to vertex and edge by another function, based on the array number. The current code looks like this and does not work for more than two bodies(i.e. if body A collides with body B, both are somewhy "blocked" for the rest of the simulation"):


Function DetectRectCollision() '''''''''''''loops through all bodies and their edges in the list to
''''''''''''find intersecting lines
Local pass% = True

Local EliminateList:TList = CreateList()


For Local Rect1:Rect = EachIn RectList
For Local Rect2:Rect = EachIn RectList

pass = True

For Local ERect:Rect = EachIn EliminateList

If (ERect = Rect1) Or (ERect = Rect2)
pass = False

EndIf
Next


If (Rect1 <> Rect2) And pass = True

ListAddLast(EliminateList, Rect1)
ListAddLast(EliminateList, Rect2)

For Local c% = 0 To 3
For Local k% = 0 To 3


Local u1#
Local u2#

Local nom1#
Local nom2#

Local denom#


Local d1x# = Rect1.LineArr[c].x
Local d1y# = Rect1.LineArr[c].y

Local d2x# = Rect2.LineArr[k].x
Local d2y# = Rect2.LineArr[k].y

Local d12x# = ((Rect1.Pos.x + Rect1.VertArr[c].x) - (Rect2.Pos.x + Rect2.VertArr[k].x))
Local d12y# = ((Rect1.Pos.y + Rect1.VertArr[c].y) - (Rect2.Pos.y + Rect2.VertArr[k].y))



nom1 = d2x * d12y - d2y * d12x
nom2 = d1x * d12y - d1y * d12x

denom = d2y * d1x - d2x * d1y


u1 = nom1/denom
u2 = nom2/denom


If (u1 > 0 And u1 < 1) And (u2 > 0 And u2 < 1) >>>>>> INTERSECTION of line segments occured


Local Cross:Vector = New Vector
Cross.Assign(c, k)

Rect1.AddIntersection(Cross) ''''''stores
each intersection as a vector in an array



EndIf


Next
Next

Rect1.ProcessIntersection(Rect2) '''''''''''''''

EndIf

Next
Next


End Function