|
@ -27,8 +27,8 @@ pub fn make_grid(ctx: &mut Context, r: u8, c: u8, board: &[Vec<u8>]) -> GameResu |
|
|
builder.rectangle( |
|
|
builder.rectangle( |
|
|
DrawMode::fill(), |
|
|
DrawMode::fill(), |
|
|
graphics::Rect { |
|
|
graphics::Rect { |
|
|
x: board::START_X + (board::BOARD_SQUARE_SIZE * col as f32), |
|
|
x: board::START_X + (board::BOARD_SQUARE_SIZE * f32::from(col)), |
|
|
y: board::START_Y + (board::BOARD_SQUARE_SIZE * row as f32), |
|
|
y: board::START_Y + (board::BOARD_SQUARE_SIZE * f32::from(row)), |
|
|
w: board::BOARD_SQUARE_SIZE, |
|
|
w: board::BOARD_SQUARE_SIZE, |
|
|
h: board::BOARD_SQUARE_SIZE, |
|
|
h: board::BOARD_SQUARE_SIZE, |
|
|
}, |
|
|
}, |
|
@ -144,8 +144,8 @@ impl EventHandler for Apr { |
|
|
if mouse::button_pressed(ctx, MouseButton::Left) && !self.dragging { |
|
|
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 * f32::from(x); |
|
|
let y = board::START_Y + board::BOARD_SQUARE_SIZE * (y as f32); |
|
|
let y = board::START_Y + board::BOARD_SQUARE_SIZE * f32::from(y); |
|
|
self.dragging = true; |
|
|
self.dragging = true; |
|
|
actor.posn = actor::ActorPosn::FloatingPosn { |
|
|
actor.posn = actor::ActorPosn::FloatingPosn { |
|
|
x, |
|
|
x, |
|
@ -186,8 +186,8 @@ impl EventHandler for Apr { |
|
|
ctx, |
|
|
ctx, |
|
|
&actor.image, |
|
|
&actor.image, |
|
|
drawparams.dest([ |
|
|
drawparams.dest([ |
|
|
board::START_X + board::BOARD_SQUARE_SIZE * (x as f32), |
|
|
board::START_X + board::BOARD_SQUARE_SIZE * f32::from(x), |
|
|
board::START_Y + board::BOARD_SQUARE_SIZE * (y as f32), |
|
|
board::START_Y + board::BOARD_SQUARE_SIZE * f32::from(y), |
|
|
]), |
|
|
]), |
|
|
)?, |
|
|
)?, |
|
|
} |
|
|
} |
|
|