Re:Game Loop
by vectorrain on Sunday January 27, 2019 @04:55AM
(#19011116)
Fair enough. I think I didn't understand the difference between game time and real time before. I though the running time of "display_game()" was the game time (curr_frame_tick - prev_frame_tick). Thanks a lot for your detailed explanation.
(curr_frame_tick - prev_frame_tick) is the delta time of each loop. So this value is the time it took to do the previous loop.
It doesn't increase each timestep because prev_game_tick is recalculated each step.
Step1 (initial step):
- prev_frame_tick = 0
- curr_frame_tick = 0
- delta = 0
Step2:
- prev_frame_tick = 0
- curr_frame_tick = 200
- delta = 200
Step3:
- prev_frame_tick = 200
- curr_frame_tick = 356
- delta = 156
...