well I have got my sprite to jump multiple times but it does not stop, I just want my sprite to jump once when I hit the space bar.
void jumpsprite()
{
positionY = -0.05f*(x*x) + 20;
x++;
if (x >= 20.0f)
{
x = -20.0f;
}
move_sprite++;
cout << positionY << endl;
}
void Loop(int value)
{
jumpsprite();
glutPostRedisplay();
glutTimerFunc(500, Loop, 0);
}
void handleKeypress(unsigned char key, int x, int y)
{
switch (key)
{
case 27:
exit(0);
break;
case 32:
// jumpsprite();
Loop(0);
break;