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....