diff --git a/src/citizen.rs b/src/citizen.rs index 374c387..e3a1ef8 100644 --- a/src/citizen.rs +++ b/src/citizen.rs @@ -200,7 +200,7 @@ pub fn citizen_movement( fn is_valid_move(tilemap: &TileMap, pos: IVec3) -> bool { // Check if the tile at current position is not blocking if let Some(current_tile) = tilemap.floor_tiles.get(&pos) { - if current_tile.1 { + if current_tile.0 != 0 { return false; } } @@ -208,7 +208,7 @@ fn is_valid_move(tilemap: &TileMap, pos: IVec3) -> bool { // Check if there's solid ground below let pos_below = pos - IVec3::new(0, 0, 1); if let Some(below_tile) = tilemap.floor_tiles.get(&pos_below) { - return below_tile.1; + return below_tile.0 != 0; } false } diff --git a/src/main.rs b/src/main.rs index 02049ec..c1f0b69 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,7 +54,7 @@ fn main() { tile::camera_z_movement, tile::update_tile_visibility .run_if(|camera_moved: Res| camera_moved.0), - // log_fps_system, + log_fps_system, ), ) .run(); diff --git a/src/tilemap.rs b/src/tilemap.rs index cb29bac..8a04be4 100644 --- a/src/tilemap.rs +++ b/src/tilemap.rs @@ -86,7 +86,7 @@ pub fn calculate_visibility(pos: IVec3, tilemap: &TileMap) -> [u32; 8] { let mut is_occluded = false; - 'vertical_check: for z_offset in 1..=35 { + 'vertical_check: for z_offset in 1..5 { let above_pos = IVec3::new(pos.x, pos.y, pos.z + (z_offset * tile_size)); if above_pos.z <= camera_z { if let Some(&(_, opaque, _, _, _)) = tilemap.floor_tiles.get(&above_pos) { @@ -95,6 +95,10 @@ pub fn calculate_visibility(pos: IVec3, tilemap: &TileMap) -> [u32; 8] { break 'vertical_check; } } + if z_offset >= 4 { + is_occluded = true; + break 'vertical_check; + } // if let Some(&(_, solid, _)) = tilemap.fixtures.get(&above_pos) { // if solid { // is_occluded = true;