corridor types, doors, some refactoring
This commit is contained in:
parent
46e0c6ec6b
commit
ab5797078c
19 changed files with 380 additions and 35 deletions
|
|
@ -10,25 +10,32 @@ pub fn apply_room_to_map(map: &mut Map, room: &Rect) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn apply_horizontal_tunnel(map: &mut Map, x1: i32, x2: i32, y: i32) {
|
||||
pub fn apply_horizontal_tunnel(map: &mut Map, x1: i32, x2: i32, y: i32) -> Vec<usize> {
|
||||
let mut corridor = Vec::new();
|
||||
for x in min(x1, x2)..=max(x1, x2) {
|
||||
let idx = map.xy_idx(x, y);
|
||||
if idx > 0 && idx < (map.width as usize) * (map.height as usize) {
|
||||
map.tiles[idx as usize] = TileType::Floor;
|
||||
corridor.push(idx as usize);
|
||||
}
|
||||
}
|
||||
return corridor;
|
||||
}
|
||||
|
||||
pub fn apply_vertical_tunnel(map: &mut Map, y1: i32, y2: i32, x: i32) {
|
||||
pub fn apply_vertical_tunnel(map: &mut Map, y1: i32, y2: i32, x: i32) -> Vec<usize> {
|
||||
let mut corridor = Vec::new();
|
||||
for y in min(y1, y2)..=max(y1, y2) {
|
||||
let idx = map.xy_idx(x, y);
|
||||
if idx > 0 && idx < (map.width as usize) * (map.height as usize) {
|
||||
map.tiles[idx as usize] = TileType::Floor;
|
||||
corridor.push(idx as usize);
|
||||
}
|
||||
}
|
||||
return corridor;
|
||||
}
|
||||
|
||||
pub fn draw_corridor(map: &mut Map, x1: i32, y1: i32, x2: i32, y2: i32) {
|
||||
pub fn draw_corridor(map: &mut Map, x1: i32, y1: i32, x2: i32, y2: i32) -> Vec<usize> {
|
||||
let mut corridor = Vec::new();
|
||||
let mut x = x1;
|
||||
let mut y = y1;
|
||||
|
||||
|
|
@ -44,8 +51,12 @@ pub fn draw_corridor(map: &mut Map, x1: i32, y1: i32, x2: i32, y2: i32) {
|
|||
}
|
||||
|
||||
let idx = map.xy_idx(x, y);
|
||||
map.tiles[idx] = TileType::Floor;
|
||||
if map.tiles[idx] != TileType::Floor {
|
||||
map.tiles[idx] = TileType::Floor;
|
||||
corridor.push(idx);
|
||||
}
|
||||
}
|
||||
return corridor;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue