all repos — hyperkaos @ main

lightweight modular puzzle/adventure game engine in C with SDL 1.2

Timer.c (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#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;
}