diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -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(); +} |