Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Okay, so I'm making a platformer, and I wanna know how I can make a arc'd jump easily. Like what Mario does in super Mario Bros 1. Any ideas on a simple way to accomplish this?

share|improve this question
add comment

2 Answers

Interesting question; having taken Physics classes, I take this sort of thing for granted, when really it is an intriguing idea.

The key point is that X and Y movements are distinct from each other. An object in motion will sustain its X motion, and its Y motion will be affected by gravity at a rate which you set.

You should track the sprite's X and Y velocities. When standing still, the sprite has an X velocity of 0; when moving, it has a constant velocity. When touching the ground, the sprite has a Y velocity of 0. When the jump button is pressed, give the sprite a Y velocity.

Now every frame, reduce the Y velocity by some amount; this is your gravity magnitude. But if the sprite is touching ground, set the Y velocity to 0 so that the sprite doesn't move into the ground. And then modify the sprite's position by (velocity*time).

Here is a decent-looking Physics lesson which demonstrates these separated velocity components: http://www.physicsclassroom.com/class/vectors/u3l2c.cfm


If this was not the answer you're looking for, and you actually mean something more complicated by an "arc'd jumping method", then please elaborate!

share|improve this answer
1  
You should add a note that the Y-component (and X too for that matter, but that's not really interesting for the question) of the velocity could be negative (being downward motion on the Y axis), and adding a negative value to the position will make it move downward. This doesn't feel obvious from the way you put it. +1 –  falstro Nov 18 '10 at 8:18
    
The Y-component in Super Mario 1 also depended on how long you held down the jump button; releasing the button would immediately set y velocity to 0 even if Mario had some previous upward momentum. Also, falling tends to have a max negative-Y velocity (you can think of this as "terminal velocity") for gameplay reasons. Lastly, there are a LOT of ways to handle the X-component -- Mega Man sets X as constant -1, 0 or +1 based on joystick position, Mario modifies progressively like gravity, Castlevania doesn't allow direction changes in mid-air at all. –  Ian Schreiber Nov 19 '10 at 19:00
add comment

ExciteMike has some great examinations of the Super Meat Boy and Super Mario 3 jump physics on his blog.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.