diff --git a/MoreInterestingDungeons/cellular/src/map_builder/automata.rs b/MoreInterestingDungeons/cellular/src/map_builder/automata.rs index 1c21dac..d22ac70 100644 --- a/MoreInterestingDungeons/cellular/src/map_builder/automata.rs +++ b/MoreInterestingDungeons/cellular/src/map_builder/automata.rs @@ -16,6 +16,7 @@ impl MapArchitect for CellularAutomataArchitect { for _ in 0..10 { self.iteration(&mut mb.map); } + self.add_boundaries(&mut mb.map); let start = self.find_start(&mb.map); mb.monster_spawns = mb.spawn_monsters(&start, rng); mb.player_start = start; @@ -71,6 +72,19 @@ impl CellularAutomataArchitect { map.tiles = new_tiles; } + fn add_boundaries(&mut self, map: &mut Map) { + for x in 1 .. SCREEN_WIDTH { + map.tiles[map_idx(x, 1)] = TileType::Wall; + map.tiles[map_idx(x, SCREEN_HEIGHT-1)] = TileType::Wall; + map.tiles[map_idx(x, 0)] = TileType::Wall; + } + for y in 1 .. SCREEN_HEIGHT { + map.tiles[map_idx(1, y)] = TileType::Wall; + map.tiles[map_idx(SCREEN_WIDTH-1, y)] = TileType::Wall; + map.tiles[map_idx(0, y)] = TileType::Wall; + } + } + fn find_start(&self, map: &Map) -> Point { let center = Point::new(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);// (10) let closest_point = map.tiles diff --git a/MoreInterestingDungeons/output_harness/src/map_builder/automata.rs b/MoreInterestingDungeons/output_harness/src/map_builder/automata.rs index c173606..794b0e5 100644 --- a/MoreInterestingDungeons/output_harness/src/map_builder/automata.rs +++ b/MoreInterestingDungeons/output_harness/src/map_builder/automata.rs @@ -85,10 +85,12 @@ impl CellularAutomataArchitect { for x in 1 .. SCREEN_WIDTH { self.map.tiles[map_idx(x, 1)] = TileType::Wall; self.map.tiles[map_idx(x, SCREEN_HEIGHT-1)] = TileType::Wall; + self.map.tiles[map_idx(x, 0)] = TileType::Wall; } for y in 1 .. SCREEN_HEIGHT { self.map.tiles[map_idx(1, y)] = TileType::Wall; self.map.tiles[map_idx(SCREEN_WIDTH-1, y)] = TileType::Wall; + self.map.tiles[map_idx(0, y)] = TileType::Wall; } }