Jump to content
  • Advertisement
Sign in to follow this  
doombunny3

Help: Gravity

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

Can someone help explain to me how to go about adding a gravity effect?

Nothing hard.. Just when you jump you come back down to the platform.

The kind of game I want to incorporate this into is only a 2d Sidescroller so nothing to fancy. Could you just explain the logic? Because i'm completely lost on how to go about this.

If it helps: I will be using SDL with C++

Share this post


Link to post
Share on other sites
Advertisement
This might help you if your looking for ACTUAL gravity
http://www.dreamincode.net/forums/topic/166013-putting-math-into-the-context-of-game-programming-part-ii-2d-gravity
Now if your looking to fake it, you just animate your character in a negative Y axis as he jumps and over a course of how fast you want the jump to be you increase his Y axis until he hits grounds.

Share this post


Link to post
Share on other sites
What you could do is have a constant downwards velocity due to gravity and whenever you're standing on a platform it counteracts this velocity change (and makes it 0). I'm assuming you understand collisions though so if you don't understand the y coordinate velocity of the player then I'll explain further.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!