Add bsp interior
This commit is contained in:
22
src/map_builders/bsp/mod.rs
Normal file
22
src/map_builders/bsp/mod.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use crate::{Map, TileType};
|
||||
|
||||
#[inline(always)]
|
||||
pub fn draw_corridor(map: &mut Map, x1: i32, y1: i32, x2: i32, y2: i32) {
|
||||
let mut x = x1;
|
||||
let mut y = y1;
|
||||
|
||||
while x != x2 || y != y2 {
|
||||
if x < x2 {
|
||||
x += 1;
|
||||
} else if x > x2 {
|
||||
x -= 1;
|
||||
} else if y < y2 {
|
||||
y += 1;
|
||||
} else if y > y2 {
|
||||
y -= 1;
|
||||
}
|
||||
|
||||
let idx = map.xy_idx(x, y);
|
||||
map.tiles[idx] = TileType::Floor;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user