Randomized rectangle placement without repetition works now. On to having multiple levels in the dungeon.

main
Zed A. Shaw 1 week ago
parent cb976a69a9
commit ffdea41faa
  1. 12
      matrix.hpp

@ -333,13 +333,15 @@ namespace matrix {
struct rectangle_t {
int x;
int y;
int top;
int left;
int right;
int width;
int height;
int right;
int bottom;
rectangle_t(MAT &mat, size_t start_x, size_t start_y, size_t width, size_t height) :
top(start_y),
left(start_x),
width(width),
height(height)
@ -368,17 +370,21 @@ namespace matrix {
struct rando_rect_t {
int x;
int y;
int x_offset;
int y_offset;
rectangle_t<MAT> it;
rando_rect_t(MAT &mat, size_t start_x, size_t start_y, size_t width, size_t height) :
it{mat, start_x, start_y, width, height}
{
x_offset = Random::uniform(0, int(width));
y_offset = Random::uniform(0, int(height));
}
bool next() {
bool done = it.next();
x = it.x;
y = it.y;
x = it.left + ((it.x + x_offset) % it.width);
y = it.top + ((it.y + y_offset) % it.height);
return done;
}
};

Loading…
Cancel
Save