Skip to content

Instantly share code, notes, and snippets.

@PoetaKodu
Created January 29, 2017 18:21
Show Gist options
  • Save PoetaKodu/9aad3014430d683e6ce0a70be737bd3a to your computer and use it in GitHub Desktop.
Save PoetaKodu/9aad3014430d683e6ce0a70be737bd3a to your computer and use it in GitHub Desktop.
sf::Clock GameClock;
// Pierwszy pomiar zostanie zakonczony dopiero na koncu pierwszej klatki.
// Na początku zakładamy, że czas klatki to idealnie 1 / 60 sekundy (60 FPS)
float DeltaTime = 1 / 60.f;
while(...)
{
float frameStartTime = GameClock.getElapsedTime().asSeconds();
// Kod pętli głównej...
//float frameEndTime = GameClock.getElapsedTime().asSeconds();
//DeltaTime = frameEndTime - frameStartTime;
// Powyższy zapis skraca się do:
DeltaTime = GameClock.getElapsedTime().asSeconds() - frameStartTime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment