Jump to content
  • Advertisement
Sign in to follow this  
ChrisRX

Jumping in a 2d platformer

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

In a platformer that I'm currently coding, the gravity is simply calculated as a constant velocity downwards until it collides with a tile. With this though, I don't know how to implement jumping. Obviously if I define gravity as a function of acceleration, then I just give the character a negative downwards velocity and it will work. Is this the way that most people code this though? Or do people tend to use some other short cut?

Share this post


Link to post
Share on other sites
Advertisement
No, that's pretty much how it's done. That is by setting a negative velocity when jumping, and continually adding the gravity constant to that each frame to get a nice parabola. Add in some simple (unaccelerated) movement on the x axis independently controlled by the joystick, include some collision detection to snap your character to the ground (and reset the velocity) and you've got basic platform game movement right there.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!