diff options
Diffstat (limited to 'src/main/game')
-rw-r--r-- | src/main/game/cell.c | 15 | ||||
-rw-r--r-- | src/main/game/game.c | 17 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/main/game/cell.c b/src/main/game/cell.c index 892dd47..53d051a 100644 --- a/src/main/game/cell.c +++ b/src/main/game/cell.c @@ -19,15 +19,26 @@ #include <stdlib.h> #include <stdbool.h> +#include <log.h> #include "cell.h" -#include "../util.h" + +static Log *log = NULL; + +static void +init_log(void) +{ + if (log != NULL) return; + log = log_create("Cell"); +} Cell * cell_new(float left, float right, float top, float bottom) { + init_log(); + Cell *cell = malloc(sizeof(Cell)); if (cell == NULL) { - log_error("Error allocating memory for cell"); + log_error(log, "Error allocating memory for cell"); exit(EXIT_FAILURE); } cell->left = left; diff --git a/src/main/game/game.c b/src/main/game/game.c index e1a193a..7579c50 100644 --- a/src/main/game/game.c +++ b/src/main/game/game.c @@ -19,10 +19,10 @@ #include <stdio.h> #include <stdlib.h> +#include <log.h> #include "../engine/engine.h" #include "game.h" #include "cell.h" -#include "../util.h" #include "../engine/ui/ui.h" float xmin, xmax, ymin, ymax; @@ -43,6 +43,15 @@ int moves = 0; static void game_draw_field(TrisGame *game, float box_size, float x, float y); +static Log *log = NULL; + +static void +init_log(void) +{ + if (log != NULL) return; + log = log_create("Game"); +} + static void draw_sign(float x, float y) { @@ -100,15 +109,19 @@ game_mouse_button_pressed(float x, float y, void *data) } } } + + check_win(); } TrisGame * game_init(int width, int height) { + init_log(); + /* Init of the TrisGame */ TrisGame *game = malloc(sizeof(TrisGame)); if (game == NULL) { - log_error("Error allocating memory for the game"); + log_error(log, "Error allocating memory for the game"); exit(EXIT_FAILURE); } game->width = width; |