diff --git a/src/apr.rs b/src/apr.rs index c04130b..4487b1d 100644 --- a/src/apr.rs +++ b/src/apr.rs @@ -14,6 +14,7 @@ pub struct Apr { board: board::Board, grid: Mesh, should_update_grid: bool, + dragging: bool, actors: Vec, behaviours: Vec, @@ -98,6 +99,7 @@ impl EventHandler for Apr { // no long clicking and dragging let (x, y) = self.board.closest_square_coords(posn.x, posn.y); actor.posn = actor::ActorPosn::BoardPosn { x, y }; + self.dragging = false; } else { actor.posn = actor::ActorPosn::FloatingPosn { x: posn.x + held_x, @@ -108,11 +110,12 @@ impl EventHandler for Apr { } } actor::ActorPosn::BoardPosn { x, y } => { - if mouse::button_pressed(ctx, MouseButton::Left) { + if mouse::button_pressed(ctx, MouseButton::Left) && !self.dragging { let (posx, posy) = self.board.closest_square_coords(posn.x, posn.y); if posx == x && posy == y { let x = board::START_X + board::BOARD_SQUARE_SIZE * (x as f32); let y = board::START_Y + board::BOARD_SQUARE_SIZE * (y as f32); + self.dragging = true; actor.posn = actor::ActorPosn::FloatingPosn { x, y,