New-world lakes start level; no trees in water (t96)
This commit is contained in:
+19
-2
@@ -190,12 +190,14 @@ function* worldSteps(seedIn, w, h) {
|
||||
}
|
||||
yield [0.72, 'Snow and trees'];
|
||||
// trees
|
||||
const trees = [];
|
||||
for (let x = 12; x < w - 12;) {
|
||||
const sy = surfY[x];
|
||||
const ok = mat[sy * w + x] === GRASS && mat[sy * w + x + 1] === GRASS && !noTree[x] && Math.abs(x - spawnX) > 6 && !(x > spawnX + 14 && x < spawnX + 72); // none where the dock goes
|
||||
if (ok && rng() < 0.7) {
|
||||
const tree = { x, y: sy - 1, cells: [] }; trees.push(tree);
|
||||
const th = 9 + Math.floor(rng() * 8);
|
||||
const setW = (xx, yy) => { if (xx < 0 || yy < 1 || xx >= w) return; const i = yy * w + xx; if (mat[i] === EMPTY) bgm[i] = WOOD; };
|
||||
const setW = (xx, yy) => { if (xx < 0 || yy < 1 || xx >= w) return; const i = yy * w + xx; if (mat[i] === EMPTY) { bgm[i] = WOOD; tree.cells.push(i, WOOD); } };
|
||||
for (let k = 1; k <= th; k++) for (let dx = 0; dx < 2; dx++) setW(x + dx, sy - k);
|
||||
// two branches
|
||||
for (const side of [-1, 1]) { const by = sy - th + 3 + Math.floor(rng() * 3); for (let k = 1; k <= 3; k++) setW(x + (side < 0 ? -k : 1 + k), by - (k >> 1)); }
|
||||
@@ -206,7 +208,7 @@ function* worldSteps(seedIn, w, h) {
|
||||
for (let yy = Math.floor(cy - r); yy <= cy + r; yy++) for (let xx = Math.floor(cx - r); xx <= cx + r; xx++) {
|
||||
if (xx < 0 || yy < 1 || xx >= w) continue;
|
||||
const ex = (xx - cx) / r, ey = (yy - cy) / (r * 0.85);
|
||||
if (ex * ex + ey * ey <= 1 && hash2(xx, yy, worldSeed + 7) % 9 !== 0) { const i = yy * w + xx; if (mat[i] === EMPTY && !bgm[i]) bgm[i] = LEAVES; }
|
||||
if (ex * ex + ey * ey <= 1 && hash2(xx, yy, worldSeed + 7) % 9 !== 0) { const i = yy * w + xx; if (mat[i] === EMPTY && !bgm[i]) { bgm[i] = LEAVES; tree.cells.push(i, LEAVES); } }
|
||||
}
|
||||
}
|
||||
x += 16 + Math.floor(rng() * 20);
|
||||
@@ -258,9 +260,24 @@ function* worldSteps(seedIn, w, h) {
|
||||
// re-ambient after settling, then start clean
|
||||
for (let i = 0; i < N; i++) { const m = mat[i]; if (m !== MAGMA) temp[i] = AMB[(i / w) | 0]; life[i] = PH[m] === PH_LIQUID && FRZ[m] ? 255 : 0; }
|
||||
tick = 0;
|
||||
// Settling can carry lakes past noTree; leave their connected low banks treeless too.
|
||||
bgm.fill(0);
|
||||
for (const tree of trees) {
|
||||
let wet = false;
|
||||
for (let root = tree.x; root <= tree.x + 1 && !wet; root++) for (const d of [-1, 1]) {
|
||||
for (let x = root; x >= 0 && x < w; x += d) {
|
||||
const m = mat[tree.y * w + x];
|
||||
if (m === WATER) { wet = true; break; }
|
||||
if (m !== EMPTY && PH[m] !== PH_GAS) break;
|
||||
}
|
||||
}
|
||||
if (!wet) for (let k = 0; k < tree.cells.length; k += 2) bgm[tree.cells[k]] = tree.cells[k + 1];
|
||||
}
|
||||
findTreeBases();
|
||||
placeDock(spawnX + 34);
|
||||
hot.fill(0); awake.fill(0); updateRoof();
|
||||
// Keep the generated grains intact, but let unfinished lakes level from the first tick.
|
||||
for (let i = 0; i < N; i++) if (mat[i] === WATER) wakeIdx(i);
|
||||
resetEconomy(); resetWeather();
|
||||
weather.base = worldWater();
|
||||
bot.x = spawnX - 2; bot.y = surfY[spawnX] - 14; bot.vx = 0; bot.vy = 0;
|
||||
|
||||
Reference in New Issue
Block a user