int current_tile;
int diff_x, diff_y;
+ int click_x, click_y;
+ int release_x, release_y;
} game_t;
static void tile_init (tile_t *tile, color_t color, int number)
if (error)
FATAL_ERROR (error->message);
- game->current_tile = game->deck.num_tiles - 1;
+ /*This line appears to be useless, has been replaced by line below*/
+ //game->current_tile = game->deck.num_tiles - 1;
+ game->current_tile = -1;
+
game->diff_x = game->diff_y = 0;
}
game->diff_y = event->y - tile_y;
}
}
-
+ if (game->current_tile == -1)
+ {
+ game->click_x = event->x;
+ game->click_y = event->y;
+ }
return TRUE;
}
static gboolean on_button_release_event (GtkWidget *widget, GdkEventButton *event, game_t *game)
{
+ if (game->current_tile == -1)
+ {
+ tile_group_t group;
+ group.num_tiles = 0;
+
+ int i, tile_x, tile_y;
+ for (i = 0; i < game->deck.num_tiles; i++)
+ {
+ tile_x = game->deck.tiles[i].x;
+ tile_y = game->deck.tiles[i].y;
+ if ( (event->x >= tile_x && game->click_x <= tile_x &&
+ event->y >= tile_y && game->click_y <= tile_y) ||
+ (event->x >= tile_x && game->click_x <= tile_x &&
+ event->y <= (tile_y + TILE_HEIGHT) && game->click_y >= tile_y) )
+ {
+ group.tiles[group.num_tiles] = game->deck.tiles[i];
+ group.num_tiles++;
+ }
+ }
+ for (i = 0; i < group.num_tiles; i++)
+ tile_print(group.tiles[i]);
+ }
+
game->current_tile = -1;
printf ("You released button %d\n", event->button);