]> git.cworth.org Git - kub/commitdiff
Fixed bug so that when no tile is clicked, no tile moves.
authorKevin Worth <kworth@mac-mini.(none)>
Wed, 14 Mar 2007 15:02:17 +0000 (11:02 -0400)
committerKevin Worth <kworth@mac-mini.(none)>
Wed, 14 Mar 2007 15:02:17 +0000 (11:02 -0400)
kub.c

diff --git a/kub.c b/kub.c
index f2fe3b22746238219b22931ef13c621e9154495d..bb29e6f05cd7b72939fd0f6bfedb7de8d7f5125c 100644 (file)
--- a/kub.c
+++ b/kub.c
@@ -446,6 +446,8 @@ static gboolean on_button_press_event (GtkWidget *widget, GdkEventButton *event,
            event->y >= tile_y && event->y <= (tile_y + TILE_HEIGHT) )
 
            game->current_tile = i;
+       else 
+           game->current_tile = -1;
     }
 
     return TRUE;
@@ -462,19 +464,20 @@ 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);
-                       
-    /* 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);
-
+    if (game->current_tile >= 0)
+    {
+       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);
+       
+       /* 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);
+    }
     return TRUE;
 }