atomises rooms and corridors

- room sorter
- rounding room corners
- dogleg and bsp corridors
- room exploder
This commit is contained in:
Llywelwyn 2023-07-23 16:44:14 +01:00
parent b7b2061228
commit 2ceb20a822
9 changed files with 411 additions and 59 deletions

View file

@ -42,20 +42,6 @@ impl BspDungeonBuilder {
n_rooms += 1;
}
// Now we sort the rooms
rooms.sort_by(|a, b| a.x1.cmp(&b.x1));
// Now we want corridors
for i in 0..rooms.len() - 1 {
let room = rooms[i];
let next_room = rooms[i + 1];
let start_x = room.x1 + (rng.roll_dice(1, i32::abs(room.x1 - room.x2)) - 1);
let start_y = room.y1 + (rng.roll_dice(1, i32::abs(room.y1 - room.y2)) - 1);
let end_x = next_room.x1 + (rng.roll_dice(1, i32::abs(next_room.x1 - next_room.x2)) - 1);
let end_y = next_room.y1 + (rng.roll_dice(1, i32::abs(next_room.y1 - next_room.y2)) - 1);
draw_corridor(&mut build_data.map, start_x, start_y, end_x, end_y);
build_data.take_snapshot();
}
build_data.rooms = Some(rooms);
}