X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=kub.c;h=d878ecdc9acc16abf1d8fff1d1c30a61ed518b61;hb=7dac5c2cce8dafae40b4b88ede02fd49a541d054;hp=f2fe3b22746238219b22931ef13c621e9154495d;hpb=5d20e3cc60eb1295ffaaeaea1660c50d2343bdd8;p=kub diff --git a/kub.c b/kub.c index f2fe3b2..d878ecd 100644 --- a/kub.c +++ b/kub.c @@ -453,6 +453,7 @@ static gboolean on_button_press_event (GtkWidget *widget, GdkEventButton *event, static gboolean on_button_release_event (GtkWidget *widget, GdkEventButton *event, game_t *game) { + game->current_tile = -1; printf ("You released button %d\n", event->button); return TRUE; @@ -462,19 +463,19 @@ static gboolean on_button_motion_event (GtkWidget *widget, GdkEventMotion *event game_t *game, cairo_t *cr) { tile_t *tile; - + tile = &game->deck.tiles[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); - + gtk_widget_queue_draw_area (widget, tile->x - 1, tile->y - 1, TILE_WIDTH + 1, TILE_HEIGHT + 2); + /* 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); - + gtk_widget_queue_draw_area (widget, tile->x - 1, tile->y - 1, TILE_WIDTH + 1, TILE_HEIGHT + 2); + return TRUE; }