|
-
Jan 27th, 2000, 09:50 AM
#1
Thread Starter
New Member
How do i make it so if a shape on screen hits another on screen shape, a message box would appear and say "oops!"?
-
Jan 30th, 2000, 06:25 AM
#2
PowerPoster
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|