diff options
author | 2025-05-21 16:34:55 +0200 | |
---|---|---|
committer | 2025-05-21 16:34:55 +0200 | |
commit | 25c0bda9ca1e436370a9e2a671d3195de0e90902 (patch) | |
tree | 821dd0b7a767f0448b0037fc59a07f4a0aea3809 /src/main/game/game.c | |
parent | bf93cf0e5209815e51a2932288029d26f2153aca (diff) | |
download | tris-25c0bda9ca1e436370a9e2a671d3195de0e90902.tar.gz tris-25c0bda9ca1e436370a9e2a671d3195de0e90902.zip |
Add a Cell list inside the TrisGame struct
Diffstat (limited to 'src/main/game/game.c')
-rw-r--r-- | src/main/game/game.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/game/game.c b/src/main/game/game.c index 72d03b1..40547cc 100644 --- a/src/main/game/game.c +++ b/src/main/game/game.c @@ -40,6 +40,8 @@ int sign = 1; int moves = 0; +static void game_draw_field(TrisGame *game, float box_size, float x, float y); + static void draw_sign(float x, float y) { @@ -102,16 +104,21 @@ game_mouse_button_pressed(float x, float y) TrisGame * game_init(int width, int height) { + /* Init of the TrisGame */ TrisGame *game = malloc(sizeof(TrisGame)); if (game == NULL) { log_error("Error allocating memory for the game"); exit(EXIT_FAILURE); } + game->width = width; + game->height = height; + game->cells = list_create(); + engine_init(width, height); ui_set_title("Tris Game"); engine_set_mouse_button_listener(game_mouse_button_pressed); - game_draw_field(0.5, 0, 0); + game_draw_field(game, 0.5, 0, 0); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { @@ -128,8 +135,8 @@ game_start() engine_loop(); } -void -game_draw_field(float _box_size, float x, float y) +static void +game_draw_field(TrisGame *game, float _box_size, float x, float y) { float half_box = _box_size / 2; engine_draw_line(x - half_box, y + half_box * 3, x - half_box, y - half_box * 3); |