Sponsored By

Newsletter #56 - Clock Problem

A problem between the clock system and fixed timestep updates, new sketches, a suggestion for SAO.

Michael Grand, Blogger

December 17, 2009

2 Min Read
Game Developer logo in a gray background | Game Developer


News

There is no news to report this week.


From the Programmer
Written by Invisible

Earlier this week I realized that there was a problem with the clock system in the engine. In order to time various events, the game uses a "clock". The state update code would use either GetTickCount() or QueryPerformanceCounter() (indirectly through a system that wrapped them). This in itself works fine, but the problem occurs due to the way the state is updated. I use a fixed timestep, which means that when the state is updated, it is being updated for a specific point in time which is most likely in the past. So the counter provided by the previously mentioned functions will be slightly incorrect for the time that the state is updating for. The problem gets worse after a "lag" spike (the program freezes for a certain amount of time for whatever reason), since the main loop will attempt to catch up and update all of those missed states at once.

The problem has been fixed by using a 0 based counter that is set to the correct time for the update that is currently being performed. The counter represents how many milliseconds are between the start of the program and the current update. The update code can access this counter using a function supplied by the core system. This also ensures that there is only one counter value throughout the update, which was not true before.


Artist's Easel
Written by GreyKnight

iScribble Sketches #14

(Click to enlarge)

(Click to enlarge)

 


Community Spotlight
Written by Jay

This week, an SAO player known as RageMan1990 suggested that a boss-like monster be added to SAO in the next update. Though it's not an original idea, the thought of having a boss brought along a discussion of what a boss would be like. Whether or not a strong boss creature is added in the future, many players will always have hopes that one will one day appear.

Read more about:

2009Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like