How to make a jump movement?

How do i implement a jumping movement when i hit the SPACE. i want to make it in such a way tat the eyey point is raise over a sequence of steps and lowered again when it reach certain limit.

void keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case ’ ':
jumping = TRUE;
break;
}
}

int main(int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (width, height);
glutInitWindowPosition (100, 100);
glutCreateWindow (“Jumping”);
init ();
glutDisplayFunc (display);
glutIdleFunc (s);
glutReshapeFunc (reshape);
glutKeyboardFunc (keyboard);
glutSpecialFunc (cursor_keys);
glutPassiveMotionFunc (mouse_motion);
glutMainLoop ();
return 0;
}

void s(void)
{
jumplimit = 1.5;
}

void display(void)
{
if(jumping == TRUE)
{
num = eyey + 0.1;
if(num < jumpLimit)
{
eyey = eyey+ 0.1;
centery =centery +0.1;
}
}

glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
calculate_lookpoint(); /* Compute the centre of interest */
gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz);
glutSwapBuffers();
}

This code just cant work? may i know where is the problem?

Yeah, this will make you jump but, if I’m not wrong, you will never return to the ground…
You could do something more or less like this:

if (state == JUMPING_UP)
{

eyey = eyey + 0.1;
centery = centery + 0.1;
if(eyey > jumpLimit) { state = JUMPING_DOWN; }

}
else if (state == JUMPING_DOWN)
{

eyey = eyey - 0.1;
centery = centery - 0.1;
if(eyey < 0.1) { state = WALKING; }

}

To make the jump more realistic, do not add/substract a constant value. Remeber that physics classes and use those easy formulas to make gravity affect the movement.

Hope it helps,
-nemesis-

What those easy formulas (for gravity)?

http://www.flipcode.com/cgi-bin/msg.cgi?showThread=00001983&forum=general&id=-1