|
|
@ -123,20 +123,20 @@ impl EventHandler for Apr { |
|
|
|
self.set_colour(r, c, (self.board[r][c] + 1) % 8)?; |
|
|
|
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
|
|
|
|