question about pausing movement of object

Hi, I have an object which is moving down a 3d plain and I want to hit a button which will stop the movement of the object for about 3 secs. How do I do it? thanks.

it depends on how you’re doing it or how you would like to do it. one way would be to add to your event handler to pause for 3 seconds.

// pseudo code
if (key_pressed(SOME_BUTTON) )
    pause(3)

// continue...

look up timers and such - that should help you out.

:regards:

if he paused in the event handler, then everything would pause, even if he wanted other things moving in the scene. One way to do it is to check the current time when the button is pressed and to not move that specific object till 3 seconds is reached.

Originally posted by godhand:
Hi, I have an object which is moving down a 3d plain and I want to hit a button which will stop the movement of the object for about 3 secs. How do I do it? thanks.
// Place in keyboard routine
if (key_press == ‘S’)
{
object_state = 0;
glutTimmerFunc( 300 (time in milliseconds), my_timmer, 0); // restart object in X time;
}

// Place in routine where the ball is updated

if (object_state) update_object(); // Only moved when object_state is logic 1

// Timmer routine
void my_timmer(int te)
{
object_state = 1; // after X time restart object

}