+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  How does SMB handle collision?
Pages: [1]
Author Topic: How does SMB handle collision?  (Read 2 times)
King of Sky
Guest
« on: April 24, 2008, 02:26:42 am »

This is my first post, so sorry if this is in the wrong area. Anyway, I'm making a new side-scroller engine for a SMB fan game, and I really need to know how SMB handles it's collision. I am currently doing it in a way that is not working at all. Also, if anyone could give me any other incite as to how SMB handles things that would be great. I would be really grateful to anyone who can give me some information on the inner workings of SMB. Please keep in mind that I am interested in more of a presudocode stand point and not in the hex and offsets. Also, if no one can help, or if I am in the wrong place I would appreciate being pointed in the right direction.

Thank you in advance.
Nightcrawler
Guest
« Reply #1 on: April 24, 2008, 07:49:06 am »

I'd guess bounding boxes. In fact, I'm almost positive there is a bounding box for Mario, at least for the later games. Though I haven't looked at the code to be 100% sure. But that's the typical 2D collision detection and simple enough to be done on the NES. More advanced methods probably weren't used on the NES.
King of Sky
Guest
« Reply #2 on: April 24, 2008, 02:07:44 pm »

So it uses one bounding box per block? That seems like it would slow the game down, and also be useless for the solid blocks under other solid blocks.
Nightcrawler
Guest
« Reply #3 on: April 24, 2008, 02:59:01 pm »

Quote from: King of Sky on April 24, 2008, 02:07:44 pm
So it uses one bounding box per block? That seems like it would slow the game down, and also be useless for the solid blocks under other solid blocks.

No. Bounding box per object such as the sprites (Mario and the enemies). There are few of those. The other blocks and what not are probably done via tile grid. You don't need any bounding box on the blocks. You just need attributes whether they are solid, walkable etc..

Why don't you just look at the commented SMB disassembly we have here on the site. That will tell you for sure if you can understand some game code.
frantik
Guest
« Reply #4 on: April 24, 2008, 03:24:59 pm »

Nightcrawler pretty much nailed it.. bounding boxes for sprites and just checking the tiles for the backgrounds.  there is actually a lot of different collision detection routines.  check the disassembly for more info
King of Sky
Guest
« Reply #5 on: April 24, 2008, 05:20:02 pm »

Quote from: Nightcrawler on April 24, 2008, 02:59:01 pm
Quote from: King of Sky on April 24, 2008, 02:07:44 pm
So it uses one bounding box per block? That seems like it would slow the game down, and also be useless for the solid blocks under other solid blocks.

No. Bounding box per object such as the sprites (Mario and the enemies). There are few of those. The other blocks and what not are probably done via tile grid. You don't need any bounding box on the blocks. You just need attributes whether they are solid, walkable etc..

Why don't you just look at the commented SMB disassembly we have here on the site. That will tell you for sure if you can understand some game code.
You mean the "SMB Memory Map?" If not could you give me a link to it? I tried a search, but it turned up only that.
Disch
Guest
« Reply #6 on: April 24, 2008, 05:25:45 pm »

http://www.romhacking.net/docs/344/  <--  SMB disassembly
Dr. Floppy
Guest
« Reply #7 on: April 27, 2008, 12:55:09 pm »

For whatever it's worth, Mario will always stomp an enemy if they meet in mid-air, provided he's moving downward at the time. By this, I mean they can mash into each other sideways, and as long as Mario is in freefall he'll win.

This can be best demonstrated on those levels wherein bullet bills fire from offscreen. There's also a goomba that wanders off a high platform about halfway through 1-2. If your timing is impeccable, you can stomp him by jumping up underneath him as he falls
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC