#include "timer.h" Timer::Timer() { init_ticks = 0; current_ticks = 0; } void Timer::start() { init_ticks = SDL_GetTicks(); current_ticks = init_ticks; } int Timer::get_ticks() { // The odd case that we overflow... // If this happens, we basically reset the timer. This isn't the most // elegant solution, but it's the best one I see. Nothing should rely // on this timer for super-precision as a result if (current_ticks < init_ticks) init_ticks = current_ticks; return current_ticks - init_ticks; }