reyandme / kam_remake

"KaM Remake" is an RTS game remake written in Delphi from scratch.
http://www.kamremake.com
GNU Affero General Public License v3.0
122 stars 29 forks source link

Tick rate fixes #156

Closed lewinjh closed 3 years ago

lewinjh commented 3 years ago

Refactored all of the periodic tasks and TTimers into a single "main loop" in TKMMain.DoIdle. It handles:

Periodic tasks like game ticks and render are scheduled so they occur at a consistent interval and we don't lose time (time slip) like we were with TTimer.

This code will not attempt to "catch up" if we something takes too long and we miss the scheduled tick (it will simply skip ahead to the next future tick schedule). The existing code in TKMGame will take care of catching up lost ticks, however it should now only occur when processing takes too long and we miss a tick.

This fixes the "jumpy" movements every ~1 second when interpolated render is on, which was caused by the TTimer not firing at a consistent rate and the "catch up" logic running two ticks at the same time to compensate.

reyandme commented 3 years ago

Looks much smoother now =)