summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index a8db2b1..ff51bb3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,13 @@
#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)
{
@@ -10,18 +16,35 @@ main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
return 1;
}
- if (atexit(LZR_Quit)) {
- LZR_Quit();
+ if (atexit(deinit)) {
+ perror("main:atexit");
+ deinit();
return 1;
}
+ if ((game = malloc(sizeof(*game))) == NULL) {
+ perror("main:malloc");
+ return 1;
+ }
+ game_init(game);
+
while (!LZR_ShouldQuit()) {
LZR_CycleEvents();
+ game_update(game);
LZR_DrawBegin();
LZR_DrawSetColor(0, 0, 0, 0);
LZR_DrawClear();
+ game_draw(game);
LZR_DrawEnd();
}
return 0;
}
+
+static void
+deinit(void)
+{
+ if (game != NULL)
+ free(game);
+ LZR_Quit();
+}