katbug/Timer.c

26 lines
399 B
C
Raw Permalink Normal View History

2019-02-04 21:24:24 +00:00
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include "Timer.h"
Timer* newTimer()
{
Timer* self = (Timer*)malloc(sizeof(Timer));
self->startTicks = 0;
return self;
}
void timeStart(Timer* self)
{
self->startTicks = SDL_GetTicks();
}
int getTicks(Timer* self)
{
if (self->startTicks)
return SDL_GetTicks() - self->startTicks;
else return 0;
}