By Mike Damert, Damert@navpoint.com.
This tutorial shows a simple way to fake gravity. Actual gravity requires collision detection with the ground, but this tutorial should give you some idea of how to do that. Also, with this tutorial, you might not land at the exact same height from which you jumped if your framerates are not uniform. This problem would be solved by doing collision detection.
We do all of the processes of jumping within the SetupFrame() function.
csTicks elapsed_time = vc->GetElapsedTicks ();
static float T = 10.0;
static float V;
static const float Vo = 9.80665;
//every frame, add elapsed time in seconds since last frame to T
T += (double)elapsed_time / 1000;
//CTRL jumps
if (kbd->GetKeyState (CSKEY_CTRL) && T >= 2.0)
   T = 0.0;
V = Vo + (-9.80665 * T);
//Sprite's velocity at time T=0.0 is g;
//At time T=2.0, its velocity becomes -g;
//these counteract, so the sprite lands at exactly the same height he jumped from
if ( T <= 2.0 )
   movable->MovePosition (CS_VEC_UP * (V/60));
Jumping relies on the equation V = Vo - g * T. I assume in this example that your game would be taking place on earth, so I make g equal to earth's gravity, 9.80665, but if you wanted to set the game on another planet, you'd only need to change that number.
The first thing I do is to make T equal to the total number of elapsed seconds since you've last jumped. From T = 0.0 to T = 2.0, you will be jumping, and after that, you'll stop. Therefore I set T initially to 10.0, so that you would not be jumping when the game started.
With regard to the actual gravity, I cheat somewhat, and set Vo to the exact same value as g. This will make the character rise for exactly one second. Then I let the character fall for one second, and at that point, I stop the motion. It would be very easy to jump higher or lower if you had collision detection set up.
The final steps are to apply the equation V = Vo - g * T, and to move, in this case an iMovable, up according to its velocity, with the final line: movable->MovePosition (CS_VEC_UP * (V/60));