in procgen/src/games/dodgeball.cpp [166:224]
void split_room(QRectF room, float thickness) {
bool will_split_width = rand_gen.rand01() < .5;
bool choice2 = rand_gen.rand01() < .5;
if (room.width() < min_dim)
will_split_width = false;
if (room.height() < min_dim)
will_split_width = true;
float rx = room.x();
float ry = room.y();
float rw = room.width();
float rh = room.height();
float gap = .25 * (rand_gen.randn(3) + 1);
float pct = 1 - gap;
if (!will_split_width) {
float wy, wh, remy;
if (choice2) {
wy = ry;
remy = ry + pct * rh;
wh = pct * rh;
} else {
wy = ry + (1 - pct) * rh;
remy = ry;
wh = pct * rh;
}
add_entity_rxy(rx + rw / 2, wy + wh / 2, 0, 0, thickness, wh / 2, LAVA_WALL);
float nextw = rw / 2 - thickness;
add_room(QRectF(rx, wy, nextw, wh));
add_room(QRectF(rx + rw / 2 + thickness, wy, nextw, wh));
add_room(QRectF(rx, remy, rw, rh - wh));
} else {
float wx, ww, remx;
if (choice2) {
wx = rx;
remx = rx + pct * rw;
ww = pct * rw;
} else {
wx = rx + (1 - pct) * rw;
remx = rx;
ww = pct * rw;
}
add_entity_rxy(wx + ww / 2, ry + rh / 2, 0, 0, ww / 2, thickness, LAVA_WALL);
float nexth = rh / 2 - thickness;
add_room(QRectF(wx, ry, ww, nexth));
add_room(QRectF(wx, ry + rh / 2 + thickness, ww, nexth));
add_room(QRectF(remx, ry, rw - ww, rh));
}
}