示例#1
0
文件: fps_test.cpp 项目: iwadon/junk
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);
}
示例#2
0
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;
		}
    }
}