summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/game/game.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/game/game.c b/src/main/game/game.c
index 19a93a0..25de722 100644
--- a/src/main/game/game.c
+++ b/src/main/game/game.c
@@ -70,8 +70,25 @@ draw_sign(float x, float y)
}
static void
+loop_cells(list_t *cells, float x, float y)
+{
+ init_log();
+
+ list_node_t *current = cells->head;
+ do {
+ Cell *cell = current->data;
+ if (cell_within_bounds(cell, x, y)) {
+ }
+ current = current->next;
+ } while (current != NULL);
+}
+
+static void
game_mouse_button_pressed(float x, float y, void *data)
{
+ TrisGame *game = data;
+ loop_cells(game->cells, x, y);
+
/* Click inside the field */
if (x >= xmin && x <= xmax && y >= ymin && y <= ymax) {
if (y >= first_row) {
@@ -181,4 +198,19 @@ game_draw_field(TrisGame *game, float _box_size, float x, float y)
half_first_col = xmin + box_size / 2;
half_second_col = xmin + (box_size / 2) * 3;
half_third_col = xmin + (box_size / 2) * 5;
+
+ /* First row */
+ list_add(game->cells, cell_new(xmin, first_col, ymax, first_row));
+ list_add(game->cells, cell_new(first_col, second_col, ymax, first_row));
+ list_add(game->cells, cell_new(second_col, xmax, ymax, first_row));
+
+ /* Second row */
+ list_add(game->cells, cell_new(xmin, first_col, first_row, second_row));
+ list_add(game->cells, cell_new(first_col, second_col, first_row, second_row));
+ list_add(game->cells, cell_new(second_col, xmax, first_row, second_row));
+
+ /* Third row */
+ list_add(game->cells, cell_new(xmin, first_col, second_row, ymin));
+ list_add(game->cells, cell_new(first_col, second_col, second_row, ymin));
+ list_add(game->cells, cell_new(second_col, xmax, second_row, ymin));
}