Collision Detection Code Error: SubScript Out OF Range?
i am writing a side scroller and am writting a collision checker using loops, so i wouldnt have to go through and check against ALL the objects on the screen....
___________________________________________
Public Sub Collision_Detection(Mainrect As RECT, fall As Boolean, NumberInArray As Integer, ComputerPlayer As Boolean)
Dim TempRect As RECT
'main rect is the rect which we are checking for collisons
'if there is a collision, fall = true
'NumberInArray is the number in the array of players
'ComputerPlayer decides how to check through players
If ComputerPlayer = False Then
For i = 1 To (NumberInArray - 1)
fall = IntersectRect(TempRect, Mainrect, destrectplayer(i))
Next i
For i = (NumberInArray + 1) To 14
fall = IntersectRect(TempRect, Mainrect, destrectplayer(i))
Next i
For i = 1 To 7
fall = IntersectRect(TempRect, Mainrect, destrectcomputer(i))
Next i
Else
For i = 1 To (NumberInArray - 1)
fall = IntersectRect(TempRect, Mainrect, destrectcomputer(i))
Next i
For i = (NumberInArray + 1) To 14
fall = IntersectRect(TempRect, Mainrect, destrectcomputer(i))
Next i
For i = 1 To 7
fall = IntersectRect(TempRect, Mainrect, destrectplayer(i))
Next i
End If
End Sub
_____________________________________
and when ever i get to the code marked in red, it crashes with subscript out of range....what does this mean? any idea what i am doing wrong ?
thanks for your help...