-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
48 lines (39 loc) · 881 Bytes
/
main.c
File metadata and controls
48 lines (39 loc) · 881 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "ecs.h"
#include "vid.h"
#include "event.h"
#include "render.h"
#include "player.h"
#include "stopwatch.h"
#include "physics.h"
#include <stdio.h>
#include <stdlib.h>
void die(const char *message) {
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
#define start(subsystem) if(!subsystem##_start()) die(subsystem##_get_error());
#define stop(subsystem) subsystem##_stop();
int main(void) {
start(event);
start(vid);
start(ecs);
start(physics);
Stopwatch s = stopwatch_start();
player_spawn();
for(;;) {
if(event_process() || event_key_pressed(ESCAPE))
goto done;
double delta_time = stopwatch_time(s);
s = stopwatch_start();
player_sys(delta_time);
physics_sys(delta_time);
vid_begin_frame();
render_sys_render();
vid_end_frame();
}
done:
stop(physics);
stop(ecs);
stop(vid);
stop(event);
}