#### Archived

This topic is now archived and is closed to further replies.

# animation and frame rate in C

This topic is 5505 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ive been developing an rpg written entirely from the ground up in C...and so far its come along nicely except theres no animation...the player can walk around skipping from tile to tile without taking steps...and the creatures and NPC''s just stand there. It''s too boring...so i now i need motion. I tried clock()...but it doesnt work...in most examples ive seen a macro ( CLOCKS_PER_SEC ) is used but not defined in the program. If i try this is gives an error and says it is undefined. I then hear its value is 1000000, but even if i define it as this...it still wont work. So what i need now is some sort of way to time my game so i can get at least 40 fps animation. I guess im looking for some kind of time function etc. Note: this is all done in old school C...not c++. Ive tried for weeks to get an answer for this i can find no where. Please for the love of god someone help me. Thanks. -Dave ca_priest@yahoo.com

##### Share on other sites
#include <time.h> that''ll give u them macros and clock things.

note, in windows at least, the clock thing isnt that accurate so your timestep calculations should be sampled over several seconds in my opinion.

----------------------------
http://www.digitalsentience.pwp.blueyonder.co.uk

##### Share on other sites
The whole problem is that when i compile the program ( in turbo c )...with time.h included, it still says that the macro is undefined...i wouldve though that it would be defined in time.h but apparently not...thanks anyway for the help

##### Share on other sites
If you are using windows, you can use the function float timeGetTime(). I have found it extreely helpful and is the tier that i love. All of the other ones retun the time in soe goofy structure... something like t_time and stuff...

check out the function here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/mmfunc_2q3p.asp

hope that helps

btw, youll need to include windows.h and prolly want to #define WIN32_LEAN_AND_MEAN which excludes rarely used winows stuff...

tazzel3d ~ dwiel

##### Share on other sites
Try CLK_TCK. You can also try a different compiler like mingw or borland''s free compiler if it doesn''t work.
Turbo C IDE has a quite useful help if you just want to look something up.

##### Share on other sites
I scrounged this up from my one of my old DOS games. I think I gad a better one though, oh well.

        typedef unsigned short WORD;WORD *clock=(WORD *)0x0000046C;    /* this points to the 18.2hz system clock. */WORD Tick(){  WORD curClock;  curClock = *clock; /*get current clock value */  *clock = *clock;  /*update  value */  return curClock;}

[edited by - Daerax on November 21, 2002 10:57:57 PM]

[edited by - Daerax on November 21, 2002 10:58:58 PM]

[edited by - Daerax on November 21, 2002 11:00:32 PM]