summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..ff51bb3
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,50 @@
+#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);
+
+ 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();
+}