View Full Version : Do I need a new thread?
benwestgarth
03-02-2004, 03:52 PM
Hi,
I am trying to write my first OpenGL app - a falling blocks tetris style game (using glut). I want the blocks to periodically descend the screen as the player positions them. What is the best way in OpenGl to perform this periodic adjustment?
Thanks,
Ben
nexusone
03-02-2004, 07:42 PM
This part is not a function of openGL, but of how you structure the program.
Since you are using GLUT, I would use one of the GLUT timer functions.
// Call in your startup code
glutTimerFunc( 10, TimeEvent, 1); // Ourtime event
static void TimeEvent(int te)
{
// animation and objects that are moving without user intervention.
My_falling_blocks_que(); // Call routine to see if a block needs to start falling.
My_falling_blocks_update(); // Call to update current falling blocks.
glutPostRedisplay(); // Update screen with new falling blocks locations.
glutTimerFunc( 100, TimeEvent, 1); // Reset our timmer, so that it is called again in 100ms.
}
void display(void)
{
Draw_blocks();
}
[This message has been edited by nexusone (edited 03-02-2004).]
[This message has been edited by nexusone (edited 03-02-2004).]
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.