Browse Source

a fix

master
e-dt 4 years ago
parent
commit
febd036128
  1. 5
      src/apr.rs

5
src/apr.rs

@ -14,6 +14,7 @@ pub struct Apr {
board: board::Board,
grid: Mesh,
should_update_grid: bool,
dragging: bool,
actors: Vec<actor::Actor>,
behaviours: Vec<behaviour::Behaviour>,
@ -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,

Loading…
Cancel
Save