fp: Update physics at a fixed rate

This commit is contained in:
doyle 2023-09-23 17:26:18 +10:00
parent 9106230079
commit a8f5aa41a5
2 changed files with 8 additions and 1 deletions

View File

@ -1121,7 +1121,13 @@ void TELY_DLL_FrameUpdate(void *user_data)
} }
} }
FP_Update(platform, game, renderer, input); Dqn_f32 const PHYSICS_STEP = 1 / 60.f;
for (game->delta_s_accumulator += input->delta_s;
game->delta_s_accumulator > PHYSICS_STEP;
game->delta_s_accumulator -= PHYSICS_STEP) {
FP_Update(platform, game, renderer, input);
}
FP_Render(game, platform, renderer); FP_Render(game, platform, renderer);
// NOTE: UI ==================================================================================== // NOTE: UI ====================================================================================

View File

@ -136,6 +136,7 @@ struct FP_GameCamera
struct FP_Game struct FP_Game
{ {
Dqn_f32 delta_s_accumulator;
uint16_t tile_size; uint16_t tile_size;
TELY_ChunkPool *chunk_pool; TELY_ChunkPool *chunk_pool;
TELY_AssetFontHandle inter_regular_font; TELY_AssetFontHandle inter_regular_font;