Clock() for Frame Independent Animation
Posted: Sat Sep 20, 2008 8:06 am
Is it safe to use clock()?
A script kiddie tool I used a while ago it simply used ticks (ie, clock()) to do get sub second time. Some research seems to indicate it's bad, it might change if you swap to another computer that fails on a multiple of 66MHz
I want to have a character affected by many forces at once, IE: wind, gravity, weapons and jumping. Traditionally I get the players original position, and then add the time on this. But with these forces, I need to get a small amount of time since last update. Being dead accurate isn't important, but if your game runs twice as slow as it should there are going to be problems. Irrlichts getFPS() has problems, and I want to keep the code cross compatible.
How do you solve this problem?
A script kiddie tool I used a while ago it simply used ticks (ie, clock()) to do get sub second time. Some research seems to indicate it's bad, it might change if you swap to another computer that fails on a multiple of 66MHz
I want to have a character affected by many forces at once, IE: wind, gravity, weapons and jumping. Traditionally I get the players original position, and then add the time on this. But with these forces, I need to get a small amount of time since last update. Being dead accurate isn't important, but if your game runs twice as slow as it should there are going to be problems. Irrlichts getFPS() has problems, and I want to keep the code cross compatible.
How do you solve this problem?