From 35465f27ed87646a18cd9298eae861f14385300e Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Thu, 23 Dec 2021 20:52:49 +0100 Subject: First commit: moves a simple thing on the screen --- src/timer.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/timer.cpp (limited to 'src/timer.cpp') 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() ); +} -- cgit v1.2.3