blob: 57a130626b5074f7736140687fb4c1d695ebca34 (
plain)
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
49
50
51
52
53
54
55
|
#include "TZR.h"
#include "cfg.h"
#include "game.h"
#include <stdio.h>
#include <stdlib.h>
static Game *game = NULL;
static void deinit(void);
int
main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
{
if (TZR_Init(.width=DWIDTH,
.height=DHEIGHT,
.target_fps=TARGET_FPS,
.pixel_perfect=true,
.mixer=false,
.title="jambase"))
return 1;
if (atexit(deinit)) {
perror("main:atexit");
deinit();
return 1;
}
if ((game = malloc(sizeof(*game))) == NULL) {
perror("main:malloc");
return 1;
}
game_init(game);
while (!TZR_ShouldQuit()) {
TZR_CycleEvents();
game_update(game);
if (TZR_DrawBegin())
return 1;
TZR_DrawSetColor(0, 0, 0, 0);
TZR_DrawClear();
game_draw(game);
if (TZR_DrawEnd())
return 1;
}
return 0;
}
static void
deinit(void)
{
if (game != NULL)
free(game);
TZR_Quit();
}
|