Is there a way to move two squares in OpenGL simultaneously?
Posted
by thyrgle
on Stack Overflow
See other posts from Stack Overflow
or by thyrgle
Published on 2010-05-10T04:49:10Z
Indexed on
2010/05/10
11:04 UTC
Read the original article
Hit count: 307
Hi, so I have a function that handles key presses in a game I'm working on in OpenGL. But, the thing is that even though I have made two squares and they both move when the correct key is pressed only one square is moved. Is there a way I can make the two squares move. This is the glutKeyboardFunc function I implimented:
void handleKeypress(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
case 'w':
glutTimerFunc(0.001, moveSquareUp, 0);
break;
case 'd':
glutTimerFunc(0.001, moveSquareRight, 0);
break;
case 's':
glutTimerFunc(0.001, moveSquareDown, 0);
break;
case 'a':
glutTimerFunc(0.001, moveSquareLeft, 0);
break;
}
}
If you need any more code just ask.
© Stack Overflow or respective owner