summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2025-05-22 00:28:31 +0200
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2025-05-22 00:28:31 +0200
commitd69c230773d63f33dccf5425c6f789fc2f447dab (patch)
tree4bc372c98a92219f46b0bba146fe03a25aa119de
parentdc9d30ee5ee98f0f4aa024385ce0516fef63305b (diff)
downloadtris-d69c230773d63f33dccf5425c6f789fc2f447dab.tar.gz
tris-d69c230773d63f33dccf5425c6f789fc2f447dab.zip
Move the 'moves' attribute inside the TrisGame struct
-rw-r--r--src/main/game/game.c7
-rw-r--r--src/main/game/game.h1
2 files changed, 4 insertions, 4 deletions
diff --git a/src/main/game/game.c b/src/main/game/game.c
index e91eb6b..f61671a 100644
--- a/src/main/game/game.c
+++ b/src/main/game/game.c
@@ -37,15 +37,13 @@ init_log(void)
log = log_create("Game");
}
-int moves = 0;
-
static void game_draw_field(TrisGame *game, float box_size, float x, float y);
static char game_next_sign(TrisGame *game);
static void
draw_sign(TrisGame *game, float x, float y)
{
- float l = 0.20;
+ float l = 0.20f;
if (game_next_sign(game) == SIGN_CIRCLE) {
engine_draw_circle(x, y, l, 120, 1);
@@ -56,7 +54,7 @@ draw_sign(TrisGame *game, float x, float y)
game->sign = SIGN_CIRCLE;
}
- moves++;
+ game->moves++;
}
static void
@@ -96,6 +94,7 @@ game_init(int width, int height)
game->height = height;
game->cells = list_create();
game->sign = SIGN_CIRCLE;
+ game->moves = 0;
engine_init(width, height);
ui_set_title("Tris Game");
diff --git a/src/main/game/game.h b/src/main/game/game.h
index b90c5fe..6b9231c 100644
--- a/src/main/game/game.h
+++ b/src/main/game/game.h
@@ -26,6 +26,7 @@ typedef struct TrisGame {
int width, height;
list_t *cells;
char sign; /* x = cross and o = circle */
+ int moves;
} TrisGame;
TrisGame *game_init(int width, int height);