How Would I go about timing how fast my game runs no matter the frame rate speed?
Limiting Frame speed does work, but I don't think frame speed is reliable on such an important aspect of game programming.
Thanks.
Printable View
How Would I go about timing how fast my game runs no matter the frame rate speed?
Limiting Frame speed does work, but I don't think frame speed is reliable on such an important aspect of game programming.
Thanks.
It is important to use time base movement so things move the same speed on all computers.Code:DWORD dwTick;
DWORD dwLast;
float framespersec;
float secsperframe;
// Before the game loop begins...
dwLast = GetTickCount();
// For each iteration of the game loop...
dwTick = GetTickCount();
framespersec = 1000.0F / (float)(dwTick - dwLast)
secsperframe = (float)(dwTick - dwLast) / 1000.0F;
dwLast = dwTick;
I hope i wrote all that right...lolCode:const float unitspersec = 0.001F;
float distancetomove = secsperframe * unitspersec;
What does / by float do?
And also, Do I put this in the main while loop before the render function, or do I put it in the frame rending function?
Thanks.
Basically what he is saying that you make your code do animations or change not by the no. of frames but the no. of seconds that have passed. If you can implement that in your code on your own then you needn't use any code that he has written, however that'[s how many people would do it.
I'd suggest getting a book on making Game Engines, it doesn't matter whether it teaches you to make 2D games or 3D, the basic structure is what matters, the rest of the resources are easilly available on the internet. It might be possible for you to find some Game Engine tutorial online, and if that works for you then why not.
Any game books you suggest?
Also I probably need to know a little more math like trig.
I'm only 16 so Id say I'm pushing a little, going into trig. :D
Oh and btw, I think I know what 1000.0f / float is. Is it dividing by floats highest point?
Means that i want the result of (dwTick - dwLast) to be casted intoCode:framespersec = 1000.0F / (float)(dwTick - dwLast);
floating point value before dividing 1000.0F by it, which is to prevent
the final result from being rounded into an integer value.