+ 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 && event->x <= (tile_x + TILE_WIDTH) &&
+ event->y >= tile_y && event->y <= (tile_y + TILE_HEIGHT) )
+
+ game->current_tile = i;
+ }
+ /*Carl's Code*/
+ tile_t *tile;
+
+ tile = &game->deck.tiles[game->current_tile];
+
+ printf ("Placing tile #%d\n", game->current_tile);
+
+ /* First, invalidate the region where the tile currently is. */
+ gtk_widget_queue_draw_area (widget, tile->x, tile->y, TILE_WIDTH, TILE_HEIGHT);
+
+ /* Then, move the tile */
+ tile->x = event->x;
+ tile->y = event->y;
+
+ /* Finally, invalidate the region where the tile is now. */
+ gtk_widget_queue_draw_area (widget, tile->x, tile->y, TILE_WIDTH, TILE_HEIGHT);
+
+ game->current_tile--;
+ if (game->current_tile < 0)
+ game->current_tile = game->deck.num_tiles - 1;