diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2021-12-23 20:52:49 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2021-12-23 20:52:49 +0100 |
commit | 35465f27ed87646a18cd9298eae861f14385300e (patch) | |
tree | 7f0256d28fa6fd5368b7a39500d080456e70be8e /src/timer.cpp |
First commit: moves a simple thing on the screen
Diffstat (limited to 'src/timer.cpp')
-rw-r--r-- | src/timer.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/timer.cpp b/src/timer.cpp new file mode 100644 index 0000000..c775a73 --- /dev/null +++ b/src/timer.cpp @@ -0,0 +1,19 @@ +#include "timer.h" + +Timer::Timer(): t0 {0} {} + +void Timer::start(){ + t0 = SDL_GetTicks(); +} +unsigned int Timer::elapsed(){ + return SDL_GetTicks() - t0; +} +void Timer::restart(){ + start(); +} +void Timer::wait(unsigned int millis){ + SDL_Delay(millis); +} +void Timer::waitUntil(unsigned int millis){ + wait( millis - elapsed() ); +} |