How do i make it so if a shape on screen hits another on screen shape, a message box would appear and say "oops!"?
Printable View
How do i make it so if a shape on screen hits another on screen shape, a message box would appear and say "oops!"?
Well, I think the easiest way of collision is a square-detection. Try this:
-
'Enemy and Shot are the two objects to check
'Collision from top-left
If Shot.Left + Shot.Width > Enemy.Left Then
If Shot.Top + Shot.Height > Enemy.Top Then
'Collision from bottom-right
If Shot.Left < Enemy.Left + Enemy.Width Then
If Shot.Top < Enemy.Top + Enemy.Height Then
'Code here
EndIf
EndIf
EndIf
EndIf
-
Of course you can take 2 if's together...
Hope this helps!
------------------
[email protected]
...
Every program can be reduced to one instruction which doesn't work.