diff --git a/src/maze.rs b/src/maze.rs index 65e293b..2335240 100644 --- a/src/maze.rs +++ b/src/maze.rs @@ -19,24 +19,6 @@ impl HexMaze { Self::default() } - /// Creates a hexagonal maze with the given radius - /// Uses axial coordinates (q, r) to create a perfect hexagon - pub fn with_radius(radius: u32) -> Self { - let mut maze = Self::default(); - let radius = radius as i32; - for q in -radius..=radius { - let r1 = (-radius).max(-q - radius); - let r2 = radius.min(-q + radius); - for r in r1..=r2 { - let pos = Hex::new(q, r); - let tile = HexTile::new(pos); - maze.0.insert(pos, tile); - } - } - - maze - } - /// Adds a new tile at the specified coordinates pub fn add_tile(&mut self, coords: Hex) { let tile = HexTile::new(coords); @@ -256,18 +238,6 @@ mod tests { } } - #[test] - fn maze_builder() { - // Test builder pattern - let maze = HexMaze::with_radius(2); - - assert_eq!(maze.len(), 19, "Radius 2 should create 19 hexes"); - assert!( - maze.get_tile(&Hex::ZERO).is_some(), - "Center hex should exist" - ); - } - #[test] fn empty_maze() { let maze = HexMaze::default(); diff --git a/src/tile.rs b/src/tile.rs index bd088e5..dc6e4f8 100644 --- a/src/tile.rs +++ b/src/tile.rs @@ -15,8 +15,8 @@ use bevy::prelude::*; #[cfg_attr(feature = "bevy", reflect(Component))] #[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct HexTile { - pub pos: Hex, - pub walls: Walls, + pub(crate) pos: Hex, + pub(crate) walls: Walls, } impl HexTile { diff --git a/src/walls.rs b/src/walls.rs index 1e00b5a..06b7473 100644 --- a/src/walls.rs +++ b/src/walls.rs @@ -17,14 +17,20 @@ pub struct Walls(u8); impl Walls { /// Adds a wall in the specified direction #[inline] - pub fn add(&mut self, direction: EdgeDirection) { - self.0 |= Self::from(direction).0; + pub fn add(&mut self, direction: T) + where + T: Into, + { + self.0 |= direction.into().0; } /// Removes a wall in the specified direction #[inline] - pub fn remove(&mut self, direction: EdgeDirection) { - self.0 &= !Self::from(direction).0; + pub fn remove(&mut self, direction: T) + where + T: Into, + { + self.0 &= !direction.into().0; } /// Returns true if there is a wall in the specified direction