swapped over to bracket-lib geometry's Rects, improved feature spawning
This commit is contained in:
parent
5a8114ec7e
commit
fcb2bd2815
15 changed files with 217 additions and 107 deletions
|
|
@ -28,13 +28,20 @@ impl RoomDrawer {
|
|||
|
||||
fn circle(&mut self, build_data: &mut BuilderMap, room: &Rect) {
|
||||
let radius = (i32::min(room.x2 - room.x1, room.y2 - room.y1) as f32) / 2.0;
|
||||
let center = room.centre();
|
||||
let center_pt = rltk::Point::new(center.0, center.1);
|
||||
let center = room.center();
|
||||
let center_pt = rltk::Point::new(center.x, center.y);
|
||||
for y in room.y1..=room.y2 {
|
||||
for x in room.x1..=room.x2 {
|
||||
let idx = build_data.map.xy_idx(x, y);
|
||||
let distance = rltk::DistanceAlg::Pythagoras.distance2d(center_pt, rltk::Point::new(x, y));
|
||||
if idx > 0 && idx < ((build_data.map.width * build_data.map.height - 1) as usize) && distance <= radius {
|
||||
let distance = rltk::DistanceAlg::Pythagoras.distance2d(
|
||||
center_pt,
|
||||
rltk::Point::new(x, y)
|
||||
);
|
||||
if
|
||||
idx > 0 &&
|
||||
idx < ((build_data.map.width * build_data.map.height - 1) as usize) &&
|
||||
distance <= radius
|
||||
{
|
||||
build_data.map.tiles[idx] = TileType::Floor;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue