Started working on a random flood function for paths to do things like fill rooms with stuff.

This commit is contained in:
Zed A. Shaw 2024-12-12 11:38:38 -05:00
parent e863bfa2fe
commit ee1e2e5bc5
5 changed files with 46 additions and 10 deletions

View file

@ -76,6 +76,23 @@ void Pathing::clear_target(const Point &at) {
$input[at.y][at.x] = 1;
}
void Pathing::random_flood(const Point from, std::function<void(Point at, int dnum)> cb) {
int from_x = from.x;
int from_y = from.y;
int dnum = $paths[from.y][from.x];
cb(from, dnum);
for(int y = from_y - 1; y <= from_y + 1; y++) {
if(y < 0 || y >= int($height)) continue;
for(int x = from_x - 1; x <= from_x + 1; x++) {
if(x >= 0 && x <= int($width)) {
dnum = $paths[y][x];
cb({size_t(x), size_t(y)}, dnum);
}
}
}
}
bool Pathing::INVARIANT() {
using dbc::check;