| 322 | } |
| 323 | |
| 324 | static bool RenderAndUpdate(GameApi* game) |
| 325 | { |
| 326 | static double lag = 0.0; |
| 327 | |
| 328 | lag += game->m_current_time_seconds - game->m_previous_time_seconds; |
| 329 | |
| 330 | int num = 0; |
| 331 | |
| 332 | bool ok = true; |
| 333 | |
| 334 | while (lag >= game->m_update_fixed_time) |
| 335 | { |
| 336 | if (num < game->m_max_updates_per_frame) |
| 337 | { |
| 338 | ok = ok && Update(game); |
| 339 | |
| 340 | game->m_update_num++; |
| 341 | num++; |
| 342 | game->m_update_time_seconds = game->m_update_num * game->m_update_fixed_time; |
| 343 | } |
| 344 | |
| 345 | lag -= game->m_update_fixed_time; |
| 346 | } |
| 347 | |
| 348 | ok = ok && Render(game); |
| 349 | |
| 350 | return ok; |
| 351 | } |
| 352 | |
| 353 | bool game_init(GameApi* game, const Core::Timer& timer, void* data) |
| 354 | { |
no test coverage detected