0
\$\begingroup\$

I'm working on a Mario bros clone with SDL and C++ (purely for educational porpuses / and for fun) I got collision detection working by using AABB collision detection and resolving one axis at a time:

  1. Check collision with X-axis first
  2. Move entity if not collision is detected
  3. Check collision with the Y-axis.
  4. Move entity if not collision is detected

This is working great! However, one thing that I really like about the original Mario bros is that tiles have some kind of "rounded" feel to them. I think this helps make the map feel more organic, see how Mario moves left when jumping on a corner in the original SNES game:

enter image description here

I thought of using a circle collider for mario instead of an AABB. This would make Mario "fall" off the tiles if you step too close to the edges. But perhaps someone knows a better approach. I've been thinking about collision detection for longer than I'd like to admit. I'd love to know if someone has a clean aproach to accomplish what the GIF shows.

\$\endgroup\$
1
  • \$\begingroup\$ I think that its not the block's collider being rounded, but Mario's. It's veeeery common that characters use a rounded shape (not necessarily sphere / circle) so they can move up slopes easily. \$\endgroup\$
    – lilKriT
    Feb 1 '21 at 5:52
1
\$\begingroup\$

Two things:

  1. As you may have noticed the entity collision box is smaller than the sprite. It is actually a rectangle, taller than wider.

  2. Do not move the entity outside of the block instantly. Move the entity out at some fixed speed.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .