README.md
December 4, 2022 ยท View on GitHub
Description
This simple function let you easily know if two objects intersect. You can use it for making games or for any other purpose.
More Info
| Submitted On | |
| By | Tarek Said |
| Level | Intermediate |
| User Rating | 5.0 (10 globes from 2 users) |
| Compatibility | VB 4.0 (32-bit), VB 5.0, VB 6.0 |
| Category | Coding Standards |
| World | Visual Basic |
| Archive File |
Source Code
Public Function Hit(Object1 As Object, Object2 As Object) As Boolean
If Object1.Left > Object2.Left - Object1.Width And Object1.Left - Object2.Width < Object2.Left And Object1.Top - Object2.Top < Object2.Top And Object1.Top > Object2.Top - Object1.Top Then Hit = True
If Object1.Left > Object2.Left - Object1.Width And Object1.Left - Object2.Width < Object2.Left And Object1.Top - Object2.Height < Object2.Top And Object1.Top > Object2.Top - Object1.Height Then Hit = True
End Function