by Aymon Fournier (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
A small function to detect collision between 2 objects!
Function IsCollide(Object1 As Object, Object2 As Object) As Boolean
Dim Ob1 As Object
Dim Ob2 As Object
Set Ob1 = Object1
Set Ob2 = Object2
If Ob1.Left < Ob2.Left + Ob2.Width And Ob1.Left + Ob1.Width > Ob2.Left And Ob1.Top < Ob2.Top + Ob2.Height And Ob1.Top + Ob1.Height > Ob2.Top Then
IsCollide = True
Else
IsCollide = False
End If
End Function
Please provide some feedback about this post.