Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / supermario collision system

Author
Message
puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 6th Jul 2011 15:12 Edited at: 6th Jul 2011 15:14
I really wonder how it notices collision from top, bottom, left, right boundlines.

as above image,I want to make like that.
so I need to get each collisions.
could you please give me a hand?

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Jul 2011 15:46 Edited at: 6th Jul 2011 15:49
Well, a popular method is box collision, not to be confused with point collision. Box collision works by elimination, like it assumes there's a collision, then does some simple checks to disprove it.

It can make it clearer to refer to the parameters as left, right, top, bottom... so if we call the boxes A (mario) and B (platforms):


So you would pass the 2 sets of box coordinates to that function, and it will assume they overlap, and check each side of A to see if theres no way there can be a collision. If all the checks fail, then there is a collision. For instance, if box A's left side is further than box B's right side - there's no way there would be a collision.

Point in box collision can yield some weird results, I prefer this technique, as it also accounts for box inside box collision - it's an overlap check, so it's fail-proof, wheras point in box can easily be broken.

For sliding collision, maybe just store the previous X and Y position and use that in a crossref check, like this:




I haven't tested it, but hopefully it will work.

Health, Ammo, and bacon and eggs!
puppysss
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location: UnCyber Space
Posted: 6th Jul 2011 16:48
oh no !! I can't believe my eyes!
It also can be made type collision like top,bottom..etc!!!!
Thank you very much!

Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.

Login to post a reply

Server time is: 2026-07-10 21:42:07
Your offset time is: 2026-07-10 21:42:07