diff --git a/src/apr.rs b/src/apr.rs index 6396fbc..9564f65 100644 --- a/src/apr.rs +++ b/src/apr.rs @@ -27,8 +27,8 @@ pub fn make_grid(ctx: &mut Context, r: u8, c: u8, board: &[Vec]) -> GameResu builder.rectangle( DrawMode::fill(), graphics::Rect { - x: board::START_X + (board::BOARD_SQUARE_SIZE * col as f32), - y: board::START_Y + (board::BOARD_SQUARE_SIZE * row as f32), + x: board::START_X + (board::BOARD_SQUARE_SIZE * f32::from(col)), + y: board::START_Y + (board::BOARD_SQUARE_SIZE * f32::from(row)), w: 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 { 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); + let x = board::START_X + board::BOARD_SQUARE_SIZE * f32::from(x); + let y = board::START_Y + board::BOARD_SQUARE_SIZE * f32::from(y); self.dragging = true; actor.posn = actor::ActorPosn::FloatingPosn { x, @@ -186,8 +186,8 @@ impl EventHandler for Apr { ctx, &actor.image, drawparams.dest([ - board::START_X + board::BOARD_SQUARE_SIZE * (x as f32), - board::START_Y + board::BOARD_SQUARE_SIZE * (y as f32), + board::START_X + board::BOARD_SQUARE_SIZE * f32::from(x), + board::START_Y + board::BOARD_SQUARE_SIZE * f32::from(y), ]), )?, } diff --git a/src/board.rs b/src/board.rs index 03a9873..a444c0a 100644 --- a/src/board.rs +++ b/src/board.rs @@ -27,11 +27,11 @@ impl Board { //First, normalise to within the grid. let mut x = x; x = x.max(START_X); - x = x.min(START_X + (BOARD_SQUARE_SIZE * self.col as f32) - 1.0); + x = x.min(START_X + (BOARD_SQUARE_SIZE * f32::from(self.col)) - 1.0); let mut y = y; y = y.max(START_Y); - y = y.min(START_Y + (BOARD_SQUARE_SIZE * self.row as f32) - 1.0); + y = y.min(START_Y + (BOARD_SQUARE_SIZE * f32::from(self.row)) - 1.0); //Then, remove the start x and y x -= START_X; diff --git a/src/main.rs b/src/main.rs index c3f80d6..18e6b7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ +#![warn( + clippy::cast_lossless +)] + use ggez::event; use ggez::{ContextBuilder, GameResult};