Results 1 to 2 of 2

Thread: Collision Detection

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    4

    Post

    How do i make it so if a shape on screen hits another on screen shape, a message box would appear and say "oops!"?

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    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
  •  



Click Here to Expand Forum to Full Width