summaryrefslogtreecommitdiff
path: root/src/timer.cpp
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2021-12-23 20:52:49 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2021-12-23 20:52:49 +0100
commit35465f27ed87646a18cd9298eae861f14385300e (patch)
tree7f0256d28fa6fd5368b7a39500d080456e70be8e /src/timer.cpp
First commit: moves a simple thing on the screen
Diffstat (limited to 'src/timer.cpp')
-rw-r--r--src/timer.cpp19
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() );
+}