Gave up on adding a buffer and I'll just let rooms be near eachother. Seems to produce interesting results anyway.
This commit is contained in:
parent
8b129aea6b
commit
74f92dfe2c
5 changed files with 45 additions and 32 deletions
|
|
@ -116,13 +116,30 @@ namespace maze {
|
|||
void Builder::randomize_rooms(size_t room_size) {
|
||||
// use those dead ends to randomly place rooms
|
||||
for(auto at : $dead_ends) {
|
||||
// moving by +1 can randomly surround rooms with walls or not
|
||||
Room cur{at.x, at.y, room_size, room_size};
|
||||
bool selected = Random::uniform(0,1) == 0;
|
||||
// skip 50% of them
|
||||
if(Random::uniform(0,1) == 0) continue;
|
||||
|
||||
// if it's out of bounds skip it
|
||||
if(selected && room_should_exist(cur)) {
|
||||
$rooms.push_back(cur);
|
||||
// get the room corners randomized
|
||||
std::array<Point, 4> starts{{
|
||||
{at.x, at.y}, // top left
|
||||
{at.x - room_size + 1, at.y}, // top right
|
||||
{at.x - room_size + 1, at.y - room_size + 1}, // bottom right
|
||||
{at.x, at.y - room_size + 1} // bottom left
|
||||
}};
|
||||
|
||||
|
||||
size_t offset = Random::uniform(0, 3);
|
||||
|
||||
// BUG: this still accidentally merges rooms
|
||||
for(size_t i = 0; i < starts.size(); i++) {
|
||||
size_t index = (i + offset) % starts.size();
|
||||
Room cur{starts[index].x, starts[index].y, room_size, room_size};
|
||||
|
||||
// if it's out of bounds skip it
|
||||
if(room_should_exist(cur)) {
|
||||
$rooms.push_back(cur);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -165,14 +182,9 @@ namespace maze {
|
|||
}
|
||||
}
|
||||
|
||||
if($rooms.size() > 0) ensure_doors();
|
||||
enclose();
|
||||
}
|
||||
|
||||
void Builder::ensure_doors() {
|
||||
// NEED TO REWRITE
|
||||
}
|
||||
|
||||
void Builder::place_rooms() {
|
||||
for(auto& room : $rooms) {
|
||||
for(matrix::rectangle it{$walls, room.x, room.y, room.width, room.height}; it.next();) {
|
||||
|
|
@ -291,6 +303,7 @@ namespace maze {
|
|||
|
||||
void Builder::make_doors() {
|
||||
for(auto room : $rooms) {
|
||||
// BUG: still makes rooms without doors, so detect if no door added and brute force one in
|
||||
perimeter(room.x, room.y, room.width, room.height, [&](auto x, auto y) {
|
||||
if($ends_map.contains({x, y})) {
|
||||
for(matrix::compass door_at{$walls, x, y}; door_at.next();) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue