Hi,
I’m creating a simulation project and I have some doubt. It’ll be helpful if you guys can guide me.
How to write multiple timer? Let’s say, I have to place an object every 33ms and there is another function to calculate the trajectory and find the time taken for the object to move.
There is another timer function to move the object with respect to the time which I find out from the function.
//-------------------------------------------
//---------------SAMPLE CODE-------------
//-------------------------------------------
float time;
main()
{
glutTimerFunc(33, Timer1, 1);
glutTimerFunc(time, Timer2, 2);
}
void Timer1(int value)
{
AddObject();
glutPostReDisplay();
glutTimerFunc(33, Timer1, 1);
}
void Timer2(int value)
{
MoveObject();
glutPostRedisplay();
glutTimerFunc(time, Timer2, 1);
}
void CalculatePath()
{
…
…
// Finding the path the object move stored in linked list…
…
}
//-------------------------------------------
Now my concern is, is this the correct way to write mulitple timer?
In the AddObject() I wanted to place a sphere in random (x,y) coordinates.
Help needed.
Thanx.