Jump to content
  • Advertisement
Sign in to follow this  
Ultimate_Fusion

super mario collision dection

This topic is 3902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all, I found the full levels .bmp from super mario world. The back ground and foreground are separate. i was thinking of doing a game using them. I was wondering how the collision detection was done on the original mario world. also any other ways of doing it would be greatfull. thanks for looking

Share this post


Link to post
Share on other sites
Advertisement
Not sure how Mario exactly did it, but it was likely close to what everyone else did in the day. I can tell you what I did on a SNES game, once upon a time.

The world was tiled, thus so was the collision. Tiles we 16 x 16, thus I maintained a two dimensional array of 8-bit numbers that represented each tile. Divide the character co-ordinates by 16 to get look ups into this.

This would only give me information that changed every sixteen pixels so as I recall, I used 1 bit of that 8 bit number to figure if the tile had more specific information about it. If it didn't, the whole 16 x 16 area couldn't be entered. If it did, then I stored a mask representing the shape of the tile as 1's and 0's for pixel perfect detection. Only a handful of tiles ever needed this.

When my character was running right I would check against his rightmost side for collisions, left for left and so on. The bottom of the character would always be the point where gravity was figured.

As an example, if the right most point of the character had been moved such that is was embedded into a tile with no further information then I would move it back to the left until it was clear and play whatever animation was required.

My game was a little more like Sonic than Mario, so the more detailed masks were used for pixel perfect undulating terrain. Even so, for the most part it only involved very simple collisions checks of points around the four corners of the character.

Share this post


Link to post
Share on other sites
I'm not sure how the NES did it, but I can think of a way of doing it..

For the most part I think box collisions would serve well. Put a marker point at the top, bottom, left and right of each object. If the boxes collide, then look at the marker points and make a decision on what should happen based on this. i.e. if marios top marker hits the bottom of a box, destroy the box. if his bottom marker hits the top of an enemy, destroy the enemy.

You would do simmilar things with the enemies colliding with walls, blocks etc.

I'm not sure how accurate this sould be for less symmetrical enemies, but I think it'd do for collisions vs goombas, blocks, etc and would be a reasonable primary check vs irregularly shaped enemies.

Share this post


Link to post
Share on other sites
Wow, great responses. I have to agree. Tile-based collision and bounding box collision should be adequate for basic platformers like mario. Pixel-perfect detection is another step up and might be required for advanced terrain.

Just be aware that Nintendo still holds the copyright to those graphics so you are not legally allowed to distribute them.

The original mario was undoubtedly tile-based for the levels. For a non-tile-based platformer like mario, check out Secret Maryo Chronicles.

Share this post


Link to post
Share on other sites
I had an idea about the tile based stuff, i think i cant figure that out from here. There are stand alone slopes that the collision detection is a diagonal line. is it better to use a different method for this because i havent got a clue about it.

cheers
UF

Share this post


Link to post
Share on other sites
If you find the tile size you'll probably see the slopes are tiles with certain angles of incline (30, 45, 60 degrees).

Share this post


Link to post
Share on other sites
hey

I just thought you might also find this article (nonoche.com - Tile-based scrolling) helpful :).

But yea, I think it would be wise to make a program that extracts all the unique tile graphics to an image (or multiple images), and have a 2d array of indices to the tile graphics making up the level/map. Hmm, I hope this makes sense, hehe.

But yea, all graphics of the original Nintendo were made of tiles, it was all part of the hardware. It's all quite tricky, so I won't bother going into it.

cya

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!