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?