|
@ -14,6 +14,7 @@ pub struct Apr { |
|
|
board: board::Board, |
|
|
board: board::Board, |
|
|
grid: Mesh, |
|
|
grid: Mesh, |
|
|
should_update_grid: bool, |
|
|
should_update_grid: bool, |
|
|
|
|
|
dragging: bool, |
|
|
|
|
|
|
|
|
actors: Vec<actor::Actor>, |
|
|
actors: Vec<actor::Actor>, |
|
|
behaviours: Vec<behaviour::Behaviour>, |
|
|
behaviours: Vec<behaviour::Behaviour>, |
|
@ -98,6 +99,7 @@ impl EventHandler for Apr { |
|
|
// no long clicking and dragging
|
|
|
// no long clicking and dragging
|
|
|
let (x, y) = self.board.closest_square_coords(posn.x, posn.y); |
|
|
let (x, y) = self.board.closest_square_coords(posn.x, posn.y); |
|
|
actor.posn = actor::ActorPosn::BoardPosn { x, y }; |
|
|
actor.posn = actor::ActorPosn::BoardPosn { x, y }; |
|
|
|
|
|
self.dragging = false; |
|
|
} else { |
|
|
} else { |
|
|
actor.posn = actor::ActorPosn::FloatingPosn { |
|
|
actor.posn = actor::ActorPosn::FloatingPosn { |
|
|
x: posn.x + held_x, |
|
|
x: posn.x + held_x, |
|
@ -108,11 +110,12 @@ impl EventHandler for Apr { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
actor::ActorPosn::BoardPosn { x, y } => { |
|
|
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); |
|
|
let (posx, posy) = self.board.closest_square_coords(posn.x, posn.y); |
|
|
if posx == x && posy == y { |
|
|
if posx == x && posy == y { |
|
|
let x = board::START_X + board::BOARD_SQUARE_SIZE * (x as f32); |
|
|
let x = board::START_X + board::BOARD_SQUARE_SIZE * (x as f32); |
|
|
let y = board::START_Y + board::BOARD_SQUARE_SIZE * (y as f32); |
|
|
let y = board::START_Y + board::BOARD_SQUARE_SIZE * (y as f32); |
|
|
|
|
|
self.dragging = true; |
|
|
actor.posn = actor::ActorPosn::FloatingPosn { |
|
|
actor.posn = actor::ActorPosn::FloatingPosn { |
|
|
x, |
|
|
x, |
|
|
y, |
|
|
y, |
|
|