Fixes a bug

This commit is contained in:
Thomas Forgione 2019-04-02 22:06:54 +02:00
parent 0bc6dcdf02
commit dec099ad32
No known key found for this signature in database
GPG Key ID: BFD17A2D71B3B5E7
1 changed files with 5 additions and 4 deletions

View File

@ -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;