-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdm_gametime.h
35 lines (29 loc) · 930 Bytes
/
dm_gametime.h
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
28
29
30
31
32
33
34
35
#ifndef DM_GAMETIME
#define DM_GAMETIME
#include <time.h>
#include "dm_defines.h"
// Gets the difference in seconds between two timespecs (ts1 - ts2)
double dm_timediff_s(struct timespec *ts1, struct timespec *ts2);
// Game Loop class
// will allow gametimer_done() to be infinitely run until it reaches the designated time
// maintains its own internal timers
struct dm_gametimer
{
double wait_s;
struct timespec ts_start;
struct timespec ts_end;
};
struct dm_gametimer dm_gametimer_new(double wait_s);
void dm_gametimer_set(double wait_s, struct dm_gametimer *gt);
bool dm_gametimer_done(struct dm_gametimer *gl);
// DeltaTimer class
// relies on an exteranal timer system to ssend in delta second snapshots
struct dm_deltatimer
{
double seconds_s;
double counter_s;
double wait_s;
};
struct dm_deltatimer dm_deltatimer_new(double wait_s);
bool dm_deltatimer_update(struct dm_deltatimer *gt, double delta_s);
#endif