Started working on a random flood function for paths to do things like fill rooms with stuff.
This commit is contained in:
parent
e863bfa2fe
commit
ee1e2e5bc5
5 changed files with 46 additions and 10 deletions
17
pathing.cpp
17
pathing.cpp
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue