blob: 7aaf2a00681639fd1b0a12f4bd71d26c1cf38942 (
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 "lzr.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 (LZR_Init(cfg)) {
LZR_Quit();
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);
if (LZR_SoundLoad("res/piou.wav", 10.0) < 0)
return 1;
if (LZR_SoundLoad("res/glass.wav", 10.0) < 0)
return 1;
while (!LZR_ShouldQuit()) {
LZR_CycleEvents();
game_update(game);
LZR_DrawBegin();
LZR_DrawSetColor(0.4, 0.3, 0.3, 0);
LZR_DrawClear();
game_draw(game);
LZR_DrawEnd();
}
return 0;
}
static void
deinit(void)
{
if (game != NULL)
free(game);
LZR_Quit();
}
|