Sign in to follow this  
doombunny3

Help: Gravity

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this