TEST_F(FpsTest, update) { FPS fps; fps.next_ticks = SDL_GetTicks() + 1000; for (int i = 0; i < 9; ++i) { SDL_Delay(100); fps.update(); EXPECT_EQ(static_cast<uint32_t>(i + 1), fps.frames); EXPECT_EQ(0U, fps.latest_frames); } SDL_Delay(100 + 50); fps.update(); EXPECT_EQ(0U, fps.frames); EXPECT_EQ(10U, fps.latest_frames); }
void Game::loop() { if (!running) { running = true; FPS fps; try { while (running) { float delta = (float)fps.update(); update(delta); render(); } } catch (InternalException &e) { std::cout << "warning: " << e.what() << "\n"; } catch (...) { throw; } } }