• Advertisement
Sign in to follow this  

How to do collision like mario with gap dash?

This topic is 909 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

I have written some simple 2D platform game now.

and i'd like to write a mario clone myself.

problem is how to do a gap dash which means when i am on running mode i can dash foward for one tile gap.

If not running,i will walk down the one tile gap,and falling down.

I think if i just change the speed,i can not promise to pass the hole tile.

cause if i stand some place i still may run exact to the hole positon.

Then i think maybe i can large the collision rectangle when i was on running mode by 1 or 2 pixels.

which can promise if it is one tile gap,i will not run down,cause i fill the whole collisioin area by enlarging the rectangle.

but i am not sure this is a good idea.

What's the usual way to do gap dash collison?

Want to learn some new and better ideas.

Share this post


Link to post
Share on other sites
Advertisement

I'm assuming it's like a dash in Mega Man X. If so, couldn't you just have something like:
 

if (ACTION == "DASH")
{
   int current_y = y;
   x = x * dash_velocity;
   y = current_y;
}

Share this post


Link to post
Share on other sites
well,Dash here is really means Run,cause mario does not have a flash burst dash like Mega man.

I'm not good at english,gap dash is some word i googled from internet.Maybe it called something else.

But i guess you know what i mean if you have played Mario.Run across one tile gap works in every version of mario

Share this post


Link to post
Share on other sites

There are three big options.

 

The easiest option is to use an update frequency that is tuned really well, so that the game will register fast running as going over the gap, and slower running as falling in. This option is probably not the most robust (can be error prone or give mixed results). HappyCoder suggested this kind of thing (post above this one).

 

The second is to have some game logic that separates fast and slow running. During fast running you can do additional checks to look ahead for gaps and prevent falling.

 

The last option is to place little level markers over gaps, like in a level editor. When the character hits them you can check to see if the character is fast running, or slow enough to fall into the gap.

Edited by Randy Gaul

Share this post


Link to post
Share on other sites

The easiest option is to use an update frequency that is tuned really well, so that the game will register fast running as going over the gap, and slower running as falling in. This option is probably not the most robust (can be error prone or give mixed results). HappyCoder suggested this kind of thing (post above this one).

Actually, I believe this is exactly what Mario used. I played different versions of Mario a lot, and IIRC the player could still fall through gaps even when running, when just speeding up (or when slowing down to normal speed).

 

Most likely, the gap-skip would happen in only one or two frames, and the gravity didn't have time to kick in in that amount of time. To increase the effect, you could also round the position of the player to integers (and round gravity to lower bounds). I think Mario does this, since it always displays the character at pixel coordinates.

Edited by tonemgub

Share this post


Link to post
Share on other sites
While the display was pixel-based, I've read from several sources over the years that the original SMB used sub-pixel and sub-sub-pixel values, both 1/16 of a step. Or interpreted differently, they shifted their decimal place by eight bits, or interpreted differently, a value of 256 equaled 1 pixel. This allowed them to fine tune motion considerably. They were the form XYZ hex values, so "0x290" is 2 full pixels plus 9/16 pixels, plus 0/256, and a value "0x1FF" is just 1/256 short of 2 pixels.

That configuration allowed them to fine tune many details, like running speeds, velocities of the many different creatures, and gravity.

Share this post


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

  • Advertisement