From ac2f139dbcf050a9d825072024c10b5b7a75719f Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Thu, 2 Nov 2023 21:28:31 +0100 Subject: [PATCH] fix tiles pos --- client/src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/main.rs b/client/src/main.rs index ae14f26..f558f69 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -121,12 +121,16 @@ fn input( // Determine the index of the tile that the mouse is currently over // NOTE: This calculation assumes a fixed window size. // That's fine for now, but consider using the windows size instead. - let x_tile: usize = (mouse_position.x / 83.0).floor() as usize; - let y_tile: usize = (mouse_position.y / 540.0).floor() as usize; - let tile = x_tile + y_tile * 13; + let mut tile_x: usize = (mouse_position.x / 83.0).floor() as usize; + let tile_y: usize = (mouse_position.y / 540.0).floor() as usize; + if tile_x > 5 { + // remove the middle bar offset + tile_x = tile_x - 1 + } + let tile = tile_x + tile_y * 12; // If mouse is outside of board we do nothing - if 25 < tile { + if 23 < tile { return; }