breakhack/src/timer.c

34 lines
428 B
C
Raw Normal View History

2017-12-05 08:30:08 +01:00
#include <SDL2/SDL.h>
#include "util.h"
#include "timer.h"
Timer* timer_create()
{
Timer *t = ec_malloc(sizeof(Timer));
t->startTime = 0;
return t;
}
void timer_start(Timer *t)
{
t->startTime = SDL_GetTicks();
}
void timer_stop(Timer *t)
{
t->startTime = 0;
}
unsigned int timer_get_ticks(Timer *t)
{
if (!t->startTime)
return 0;
return SDL_GetTicks() - t->startTime;
}
void timer_destroy(Timer *t)
{
free(t);
}