🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

FPS counter

Started by
1 comment, last by ZomeonE 24 years, 5 months ago
How do I implement a FPS (frames per second) counter in my game? I'm using Win32 and DirectDraw. (I don't think that will help, except maybe the win32 thing =) Please give me some code to work on. =) Edited by - ZomeonE on 1/17/00 12:57:15 PM
Advertisement
We went over this one pretty thoroughly last week (or so). Try doing a search in the forum for FPS or frames per second. But basically it''s about counting how many frames occur in a given period of time. Then dividing.
Put this piece of code at the end of your main program loop function:

curGameFrame+=1;
curFPS = curGameFrame/((GetTickCount()-tickZero)/1000);
curSec = (GetTickCount()-tickZero)/1000;

GetTickCount() returns the number of MILLISECONDS that have gone by, so you must divide by 1000 to get seconds.

Here are the inits for the VERY BEGINNING of the program:

double curGameFrame = 0;
double tickZero = GetTickCount();
double curFPS=0;
double curSec=0;

Hope this helps.

This topic is closed to new replies.

Advertisement