From 43d0361260932077b5d7ffa01ef548c19f409cb2 Mon Sep 17 00:00:00 2001 From: iamsosmart19 Date: Thu, 30 Dec 2021 16:30:28 +1100 Subject: [PATCH] Renamed global SIZE to BOARD_SQUARE_SIZE --- src/main.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index bfc6158..8780373 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use std::path; const START_X: f32 = 20.0; const START_Y: f32 = 20.0; -const SIZE: f32 = 20.0; +const BOARD_SQUARE_SIZE: f32 = 20.0; struct Apr { row: i32, @@ -36,10 +36,10 @@ fn make_grid(ctx: &mut Context, r: i32, c: i32, board: &[Vec]) -> GameResult builder.rectangle( DrawMode::fill(), graphics::Rect { - x: START_X + (SIZE * col as f32), - y: START_Y + (SIZE * row as f32), - w: SIZE, - h: SIZE, + x: START_X + (BOARD_SQUARE_SIZE * col as f32), + y: START_Y + (BOARD_SQUARE_SIZE * row as f32), + w: BOARD_SQUARE_SIZE, + h: BOARD_SQUARE_SIZE, }, match board[row as usize][col as usize] { 0 => Color::WHITE, @@ -100,16 +100,16 @@ impl Apr { //First, normalise to within the grid. let mut x = x; x = x.max(START_X); - x = x.min(START_X + (SIZE * self.col as f32) - 1.0); + x = x.min(START_X + (BOARD_SQUARE_SIZE * self.col as f32) - 1.0); let mut y = y; y = y.max(START_Y); - y = y.min(START_Y + (SIZE * self.row as f32) - 1.0); + y = y.min(START_Y + (BOARD_SQUARE_SIZE * self.row as f32) - 1.0); //Then, snap to top left. - x = (x / SIZE).trunc() * SIZE; - y = (y / SIZE).trunc() * SIZE; + x = (x / BOARD_SQUARE_SIZE).trunc() * BOARD_SQUARE_SIZE; + y = (y / BOARD_SQUARE_SIZE).trunc() * BOARD_SQUARE_SIZE; (x, y) }