View Full Version : AHHH its the timer crisis
05-31-2001, 05:00 PM
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??
06-01-2001, 12:37 AM
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;
endtime = currenttime;
timetaken = endtime-starttime;
// assuming your timer reports in 1000's of a second
scalar = timetaken/1000.0f;
06-02-2001, 10:26 AM
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
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.