diff --git a/src/map.rs b/src/map.rs index 2622a92..5391674 100644 --- a/src/map.rs +++ b/src/map.rs @@ -87,7 +87,7 @@ pub struct TileBundle { pub transform: Transform, pub collider: Collider, pub rigid_body: RigidBody, - pub map_obstruction: Obstacle, + pub obstacle: Obstacle, } impl Default for TileBundle { @@ -96,7 +96,7 @@ impl Default for TileBundle { transform: default(), collider: Collider::rectangle(1., 1.), rigid_body: RigidBody::Static, - map_obstruction: default(), + obstacle: default(), } } } @@ -104,7 +104,7 @@ impl Default for TileBundle { impl TileBundle { pub fn new(x: i32, y: i32) -> Self { Self { - transform: Transform::from_xyz(x as f32 + 0.5, y as f32 + 0.5, 0.).into(), + transform: Transform::from_xyz(x as f32 + 0.5, y as f32 + 0.5, 0.), ..default() } } @@ -172,21 +172,24 @@ impl MapFilter for GridBuilder { let half_height = self.room_height / 2; for y in 0..self.height_in_rooms { for x in 0..self.width_in_rooms { + // println!("({x}, {y}): "); let x_offset = x * (self.room_width + 1); let y_offset = total_height - (y + 1) * (self.room_height + 1) - 1; + // println!("Offsets: {x_offset}, {y_offset}"); let room = MRect::new_i32( x_offset as i32 + 1, y_offset as i32 + 1, self.room_width as i32, self.room_height as i32, ); + // println!("{room:?}"); map.add_room(room); let coords = maze_generator::prelude::Coordinates::new(x as i32, y as i32); if let Some(field) = maze.get_field(&coords) { use maze_generator::prelude::Direction::*; if field.has_passage(&North) { let x = x_offset + half_width; - let y = y_offset + self.room_height; + let y = y_offset + self.room_height + 1; map.set_tile(x, y, Tile::floor()); } if field.has_passage(&South) { @@ -195,7 +198,7 @@ impl MapFilter for GridBuilder { map.set_tile(x, y, Tile::floor()); } if field.has_passage(&East) { - let x = x_offset + self.room_width; + let x = x_offset + self.room_width + 1; let y = y_offset + half_height; map.set_tile(x, y, Tile::floor()); }