Capped terrain peaks

This commit is contained in:
zenoamaro committed 2019-06-29 19:49:33 +02:00
1 parent cd084cc3e6
commit 1bf0406bec
1 file changed
+5 -3
+5 -3
View File
@@ -27,10 +27,12 @@ const TERRAIN_TYPES = {
let dy = 0;
for (let x=0; x<width; x++) {
if (x % stepSize === 0) dy = ((random(.3, .7)*height)-cy)/stepSize;
if (x % stepSize === 0) dy = ((random(.3, .7) * height) - cy) / stepSize;
if (x % (stepSize/16) === 0) dy = dy - random(-1, 1);
cy = clamp(0, Math.round(cy + dy), height);
drawRect(ctx, x, cy, 1, height-cy, ctx.color);
const ty = clamp(0, cy + dy, height);
const wy = clamp(70, ty, height-70);
cy = wy + (ty-wy) * 0.5;
drawRect(ctx, x, Math.round(cy), 1, Math.round(height-cy), ctx.color);
}
cacheImageData(ctx);