🎉 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!

Timer in Arcadegame

Started by
0 comments, last by Zleik 24 years, 6 months ago
I try to use a high-resoloution timer in my 2d-arcade-game: I get the frame time of the last frame and then move my ships by Movement_per_Second * frametime but the result is, that the ships are really shaking, because the frametime is changing extremly (nearly everything between 30-60 btw: someone has told me that the Fps can only be numbers like 30, 45, 60 and never something like 33 is this correct ? why ?)

So, has anyone a idea how I can stabilize this ? At the moment I am checking the Frametime at the beginning of the game during an graphical effect, calculating the average of 200 Frames and using this number for the rest of the game, but I am still wondering why the above doesn't work and why the frametime is changing that much....

Advertisement
First of all, the fps is not restricted to to 30, 45, and 60. thats absurd.

Second, why time your game into the frame time so much???
instead pass each object in the game the ammount of time that has passed since it was last called.

code:
BOOL SomeFunct(){DWORD LastTime, CurrentTime;// last time is allready setCurrentTime=GetTicksCount()// win32 function returning milisecondsUpdateScreen((CurrentTime-LastTime)/1000);//convert time from miliseconds to secondsLastTime=CurrentTime;return TRUE;}void UpdateScreen(float Time){// time in seconds since last callShipX+=(Time*MOVEMENT_PER_SEC);//move the ship}

Its not the most perfect code ever, but i think it conveys the general idea.

[This message has been edited by Enix (edited December 14, 1999).]

[This message has been edited by Enix (edited December 14, 1999).]

This topic is closed to new replies.

Advertisement