Do some tuning

This commit is contained in:
Miloslav Ciz 2024-09-10 21:49:23 +02:00
parent 4754b33dfe
commit b6d28c2886
4 changed files with 70 additions and 16 deletions

10
game.h
View file

@ -170,6 +170,9 @@ uint8_t LCR_gameStep(uint32_t time)
LCR_keyStates[i] = LCR_keyPressed(i) ?
(LCR_keyStates[i] < 255 ? LCR_keyStates[i] + 1 : 255) : 0;
if ((LCR_racing.tick % 32) == 0)
printf("speed: %d\n",LCR_racingGetCarSpeed());
uint32_t sleep = 0;
if (LCR_keyStates[LCR_KEY_B] == 1)
@ -193,6 +196,8 @@ uint8_t LCR_gameStep(uint32_t time)
LCR_game.nextRacingTickTime += LCR_RACING_TICK_MS;
}
sleep = (3 * (LCR_game.nextRacingTickTime - time)) / 4;
if (time >= LCR_game.nextRenderFrameTime)
{
LCR_GameUnit physicsInterpolationParam = LCR_GAME_UNIT -
@ -260,7 +265,10 @@ LCR_GameUnit physicsInterpolationParam = LCR_GAME_UNIT -
}
}
else
sleep = LCR_game.nextRenderFrameTime - time;
{
uint32_t tmp = (3 * (LCR_game.nextRenderFrameTime - time)) / 4;
sleep = tmp < sleep ? tmp : sleep;
}
if (sleep)
LCR_sleep(sleep);