← Ancient and prehistory3D assetfogon/stone-low-wall
Muro bajo de piedra
Drag to turn it// «Muro bajo de piedra» · propio
// A low sandstone wall, waist high: big warm tan blocks with mortar lines and a paler capstone along the top.
// A low sandstone wall, waist high: big blocks in courses with mortar lines and a paler capstone.
const stone = ["#a88250", "#b8925a", "#c5a068", "#d0ad74", "#dab982"];
const mortar = "#8a6a40";
const cap = ["#d6c08f", "#e2cea0", "#ecdab0", "#f3e4c0"];
const clampi = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
const X0 = 2, X1 = 45, Y0 = 19, Y1 = 28, TOP = 12;
const hash = (a, b) => {
const s = Math.sin(a * 12.9898 + b * 78.233) * 43758.5453;
return s - Math.floor(s);
};
// The colour of a point of a face: u runs along the face.
function blockAt(u, z) {
const row = Math.floor(z / 4);
const len = 9 + (row % 2);
const shift = (row % 2) * 5 + ((row * 3) % 4);
const k = Math.floor((u + shift) / len);
if (z % 4 === 3 || (u + shift) % len === 0) return mortar;
let tone = 1 + Math.floor(hash(k, row) * 3);
if (z < 4) tone--;
if (z > 8) tone++;
if (rand() < 0.12) tone--;
return stone[clampi(tone, 0, 4)];
}
for (let x = X0; x <= X1; x++)
for (let y = Y0; y <= Y1; y++)
for (let z = 0; z <= TOP; z++) {
const side = x === X0 || x === X1;
set(x, y, z, blockAt(side ? y + 3 : x, z));
}
// The capstone: wider than the wall, cut in long slabs.
for (let x = X0 - 1; x <= X1 + 1; x++)
for (let y = Y0 - 1; y <= Y1 + 1; y++)
for (let z = TOP + 1; z <= TOP + 2; z++) {
const joint = (x + 4) % 12 === 0;
let tone = z === TOP + 2 ? 2 : 1;
if (y === Y0 - 1 && z === TOP + 2) tone = 3;
if (rand() < 0.14) tone--;
set(x, y, z, joint ? "#b59c6c" : cap[clampi(tone, 0, 3)]);
}
// A chipped corner.
set(X1 + 1, Y0 - 1, TOP + 2, null);
set(X1 + 1, Y0 - 1, TOP + 1, null);
set(X0 - 1, Y1 + 1, TOP + 2, null);import { draw } from "./assets/voxel";
import { stoneLowWall } from "./assets/stone-low-wall";
// Every frame: standing on (x, y), the centre of its base.
draw(ctx, stoneLowWall, x, y, { size: 64, angle: 0, t: performance.now() / 1000 });
// size: its longest side, in px
// angle: turn on the floor, in radians
// t: seconds; if it moves, that animates it# In a terminal, in the game's folder
fogon assets add stone-low-wall
# With Fogón's tools (connector)
add_assets({ slug: "<your-game>", ids: ["stone-low-wall"] })
# It lands in client/assets/stone-low-wall.ts
# https://fogon.gg/object/stone-low-wall