Browse Source

Fixed a bug

master
e-dt 4 years ago
parent
commit
eb372464c0
  1. 6
      src/main.rs

6
src/main.rs

@ -124,19 +124,19 @@ impl EventHandler for Apr {
self.__TEST_state += 1;
}
let posn = mouse::position(ctx);
if self.__test_pawn_held {
if !mouse::button_pressed(ctx, MouseButton::Left) { // no long clicking and dragging
let (x, y) = self.closest_square_coords(self.__test_pawn_x, self.__test_pawn_y);
let (x, y) = self.closest_square_coords(posn.x, posn.y);
self.__test_pawn_x = x;
self.__test_pawn_y = y;
self.__test_pawn_held = false;
} else {
let posn = mouse::position(ctx);
self.__test_pawn_x = posn.x + self.__test_pawn_h_x;
self.__test_pawn_y = posn.y + self.__test_pawn_h_y;
}
} else {
if mouse::button_pressed(ctx, MouseButton::Left) {
let posn = mouse::position(ctx);
let posx = posn.x;
let posy = posn.y;
if posx >= self.__test_pawn_x && posx <= self.__test_pawn_x + 20.0 && posy >= self.__test_pawn_y && posy <= self.__test_pawn_y + 20.0 { //In real game don't hardcode size

Loading…
Cancel
Save