From dec099ad32088ea17942a3b241aa0b9a4e09646f Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Tue, 2 Apr 2019 22:06:54 +0200 Subject: [PATCH] Fixes a bug --- src/engine/map/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/engine/map/mod.rs b/src/engine/map/mod.rs index e12ec12..bcc2302 100644 --- a/src/engine/map/mod.rs +++ b/src/engine/map/mod.rs @@ -336,8 +336,9 @@ impl Map { self.collision_tiles[(i, j)] = tile; // Refresh the current graphic tile and their neighbours - for i in (i - 1) ..= (i + 1) { - for j in (j - 1) ..= (j + 1) { + use std::cmp::max; + for i in max(i, 1) - 1 ..= (i + 1) { + for j in max(j, 1) - 1 ..= (j + 1) { let new_tile = self.graphic_tile(i, j); if let Some(tile) = self.graphic_tiles.get_mut(i, j) { *tile = new_tile; @@ -399,8 +400,8 @@ impl Map { let mut collision_y = false; let mut new = new; - for col in min_col..=max_col { - for row in min_row..=max_row { + for col in min_col ..= max_col { + for row in min_row ..= max_row { let tile_left = col as f32 * SPRITE_SIZE_F32; let tile_top = row as f32 * SPRITE_SIZE_F32;