Results 1 to 10 of 10

Thread: Collision Detection And Objects.....

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2001
    Posts
    22

    Collision Detection And Objects.....

    ok i am tring to write a multi-collision detection function that will check through all objects in an array......heres the source code.....

    __________________________________________________
    Class Object "Player" with collision detection method.....
    __________________________________________________

    Private fall As Boolean
    Private DestRectPlayer As RECT

    Public Property Get fallo() As Boolean
    fall = fall
    End Property

    Public Property Let DestinationRect(NewValue As RECT)
    DestinationRect = NewValue
    End Property

    Public Property Get DestinationRect() As RECT
    DestinationRect = DestRectPlayer
    End Property


    Public Sub MultiCollision(ObjectArray As Object, PartOfArray As Boolean, NumberInArray As Integer, TotalNumberInArray As Integer)

    If fall = True Then
    Exit Sub
    End If

    Dim TempRect As RECT

    If PartOfArray = True Then

    For i = 1 To (NumberInArray - 1)
    fall = IntersectRect(TempRect, DestRectPlayer, ObjectArray(i).DestinationRect)
    If fall = True Then
    Exit Sub
    End If
    Next i

    For i = (NumberInArray + 1) To TotalNumberInArray
    fall = IntersectRect(TempRect, DestRectPlayer, ObjectArray(i).DestinationRect)
    If fall = True Then
    Exit Sub
    End If
    Next i

    Else

    For i = 1 To TotalNumberInArray
    fall = IntersectRect(TempRect, DestRectPlayer, ObjectArray(i).DestinationRect)
    If fall = True Then
    Exit Sub
    End If
    Next i

    end if

    End Sub

    ______________________________________
    Form Calling It....
    ______________________________________

    Dim objPlayers(1 To 10) As New Class1

    Private Sub Form_Load()

    With objPlayers(1).DestinationRect
    .Right = 30
    .Bottom = 30
    End With

    With objPlayers(4).DestinationRect
    .Left = 15
    .Top = 15
    .Bottom = 45
    .Right = 45
    End With

    Call objPlayers(1).MultiCollision(objPlayers, True, 1, 10)

    End Sub

    ___________________________________________________
    Module With Inserect API....
    __________________________________________________

    public Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long

    _______________

    when ever i run it i get a "byref argument type miss matched" error highlighting the "objplayers(1)" when calling it....now to me that sounds like i have spelt .DestinationRect wrong in the function...but i havent......i have been trying to figure this out for 2 days......any help please?

    Thanks in advance....
    Last edited by JSG; Sep 24th, 2001 at 10:42 PM.
    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