how to move based on time ??

hi i want to move objects and quads by time and not by step every frame you know what i mean how should i start? an easy aproach please! it is important and i dont know tis yet :frowning:

doodlemunch,
First, define the speed (e.g: units per second) of a moving object then measure the elapsed time for each frame.
The delta distance to move for each frame can be computed like this;

dt = currTime - prevTime;
distance = speed * dt;

You need a timer to measure at least millisecond precision.

Hi,

You need a clock of some sort. The clock can be used to update whatever you’re doing at a particular time interval (e.g. 5 ms).

On Windows, I’ve used QueryPerformanceCounter(), but there are other clocks available (DirectX, etc.). There are probably similar things available for other platforms.

I’ve got some code that shows how to use the Performance Counter if you need it.

Cheers,

Chris

i could not find much info about the perf counter only msdn but i did not quite get it :frowning:

Not a GL question but…

#define _NO_OLDNAMES 1
#include <sys/timeb.h>

double system_clock;
struct _timeb tm;
_ftime (&tm);
system_clock= static_cast<double> (tm.time);
system_clock += static_cast<double> (tm.millitm*.001);