Advertisement

C time functions for frame rate

Started by November 22, 2002 10:26 PM
1 comment, last by ca_priest 21 years, 11 months ago
What time functions can i use to implement animation in my rpg? My rpg is written from the ground up entirely in plain old c ( not c++ )...ive tried clock(), but it doesnt work...the macro needed to use it isnt included in time.h or any other header file and no matter what value i try for it i still get nothing. I heard to use timegettime()...anyone have experience with this? Can anyone give some example code of how this is used...i take it that you need to include windows.h to use it...and advice or help with this is greatly appreciated...thanks -DAVE ca_priest@yahoo.com
...and that's where I saw the leprechaun...he told me to burn things.
DWORD OldTime,NewTime,TimeElapsed;

OldTime = timeGetTime();
NewTime = timeGetTime();
TimeElapsed = NewTime - OldTime;

easy enough... That''ll get you the time in milliseconds since the computer was booted. It isn''t that hard to figure out the rest if you''ve written an rpg from the ground up. You could also use GetTickCount()... I''m not sure what the difference is between the two. If you want something more precise look into QueryPerformanceCounter() but timeGetTime should suit your needs perfectly.

Hope that helps
Advertisement
Ok thanks alot that seems straight forward enough...but one problem...when i compile this i get an error: Unexpected end of file in conditional stated on line 0...this refers to windows.h......i looked at windows.h and from what i can tell didnt have any errors or bad modifications to it...should i try using a diffrent windows.h maybe?...other than that thanks for the help
-Dave
ca_priest@yahoo.com
...and that's where I saw the leprechaun...he told me to burn things.

This topic is closed to new replies.

Advertisement