Results 1 to 4 of 4

Thread: Collision Detection Code Error: SubScript Out OF Range?

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2001
    Posts
    22

    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...
    Last edited by JSG; Sep 11th, 2001 at 05:33 AM.
    Two Wrongs May Not Make A Right, But Three Rights Make A Left....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width