AHHH its the timer crisis

Ok, iv’e read NeHe’s tutorial on creating a timer and all of that but I’m not sure if that code fits my case. I want the screen to render fast but I want only certain things in my scene to be slowed down (because now they are way too fast). This is much like how it is in modern games; a screen could render 20fps or 100fps but all the moving objects move at the same speed in both cases. How can I do this??

Thanks!

Position+=Velocity*dtime;

Where dtime is the time it took to draw previous frame. Use timeGetTime() or QueryPerformanceCounter() to calculate dtime, assuming your in windows.

dont forget set your movement to units per second… then work from a scalar value which represtents how long in seconds the last frame took to render.

float starttime, endtime, timetaken, scalar;

 float movespeed = 10; // move at 10 units per sec
 starttime = currenttime;
 render();
 endtime = currenttime;
 timetaken = endtime-starttime;
 // assuming your timer reports in 1000's of a second
 scalar = timetaken/1000.0f;
 position+=movespeed*scalar;

How do you round a floating-point number into an integer?

on a similar thread u all might wanna have a looksy at this http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-MainLoopTimeSteps&forum=totd&id=-1