Mark's frametweening code - 60fps or 20fps?

Blitz3D Forums/Blitz3D Programming/Mark's frametweening code - 60fps or 20fps?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

(from John Blackledge's post)
Someone suggested that the variable 'ticks' might sometimes be zero, and that this would be a bad idea.
So I added:

If ticks<1 Then ticks = 1

before

For k=1 To ticks

Do NOT do this! I think that this was the reason for my characters 'speed-walking' every so often.
As soon as I removed it the problem went away. I guess it's a case of 'trust Mark's code'.


I find it quite strange that two people so far have wanted to fiddle with the ticks calculation. Your time would be better invested in understanding the original code. It's not terribly complicated. Allow me to try to explain, and feel free to ask questions:

It renders as frequently as possible, updating the game as many times as necessary to keep the GAME (not the graphics) running at gameFPS (which should be called gameTPS - ticks per second.) The graphics will run at the fastest FPS possible. After every render, it checks how much time has passed and determines how many game updates (ticks) need to be calculated to bring the game back up to speed.

It's all about keeping the game running at a constant speed. If the game updates are taking a long time to calculate, several game updates may need to be done before rendering (ticks > 1). If the game updates are not taking very long to calculate, there may be time to render a single game update multiple times (ticks = 0). Frame tweening makes rendering the same game update multiple times look good.