VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Collision Detection Function

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!

Rate Collision Detection Function


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.

Download this snippet    Add to My Saved Code

Collision Detection Function Comments

No comments have been posted about Collision Detection Function. Why not be the first to post a comment about Collision Detection Function.

Post your comment

Subject:
Message:
0/1000 characters