pchukwura
11-18-2010, 10:01 AM
Just wondering what is recommended for maintaining a steady framerate with sprite animation ?
The only thing that looks useful is the clock() and CLOCKS_PER_SEC macro. (time.h)
My theory would be to:
Divide CLOCKS_PER_SEC by the frame rate you desire, say 12 (for 12 FPS)
Get the difference in time of cock() and the last frame value of clock().
If the difference is equal to or greater than CLOCKS_PER_SEC/12 then the next frame of the animation should be displayed
Would this be a correct assumption?
I'm trying to stick to C/C++ as much as possible so the core engine wouldn't be tied to the platform, which is why i'm avoiding the usage of NSDate, NSTimeInterval and such.
Thanks!
The only thing that looks useful is the clock() and CLOCKS_PER_SEC macro. (time.h)
My theory would be to:
Divide CLOCKS_PER_SEC by the frame rate you desire, say 12 (for 12 FPS)
Get the difference in time of cock() and the last frame value of clock().
If the difference is equal to or greater than CLOCKS_PER_SEC/12 then the next frame of the animation should be displayed
Would this be a correct assumption?
I'm trying to stick to C/C++ as much as possible so the core engine wouldn't be tied to the platform, which is why i'm avoiding the usage of NSDate, NSTimeInterval and such.
Thanks!