← CiudadObjeto 3Dfogon/jersey-barrier
Barrera de hormigón
Arrastrá para girarlo// «Barrera de hormigón» · propio
// A concrete jersey barrier: wide base tapering to a narrow top, grey with darker stains, yellow and black hazard stripes painted along the top edge.
// A concrete jersey barrier along x: a wide foot, a slope and a narrow wall, hazard stripes along the top.
const GREY = { base: "#a9aba7", light: "#babcb8", dark: "#929490", stain: "#7c7e7a", top: "#c6c8c4" };
const YELLOW = "#f2c230", YELLOW_TOP = "#f8d34f", BLACK = "#26272a";
const X0 = 2, L = 44, H = 22, MID = 23.5;
// Half the width at each height.
const half = (z) => (z <= 2 ? 8 : z <= 7 ? 8 - (z - 2) * 0.8 : 4 - (z - 7) * 0.075);
// Where the rain has run down from the stripes.
const streaks = {};
for (let n = 0; n < 14; n++) streaks[X0 + 2 + Math.floor(rand() * (L - 4))] = 3 + Math.floor(rand() * 8);
for (let x = X0; x < X0 + L; x++)
for (let z = 0; z < H; z++) {
const u = x - X0, end = Math.min(u, L - 1 - u);
// Two slots at the bottom let the water through (and the forks of a loader in).
if (z < 2 && ((u >= 9 && u <= 14) || (u >= L - 15 && u <= L - 10))) continue;
const h = half(z) - (end === 0 ? 1 : 0);
for (let y = Math.ceil(MID - h); y <= Math.floor(MID + h); y++) {
// The groove at each end where the next barrier locks in.
if (end === 0 && Math.abs(y - MID) < 1 && z >= 4 && z <= 17) continue;
let c;
if (z >= H - 5) {
c = (x + z) % 8 < 4 ? (z === H - 1 ? YELLOW_TOP : YELLOW) : BLACK;
if (rand() < 0.05) c = GREY.base; // chipped paint
} else {
c = rand() < 0.14 ? GREY.light : rand() < 0.12 ? GREY.dark : GREY.base;
if (z <= 2 && rand() < 0.55) c = GREY.dark;
if (z === 0 && rand() < 0.4) c = GREY.stain;
if (streaks[x] && z >= H - 5 - streaks[x]) c = rand() < 0.75 ? GREY.stain : GREY.dark;
if (z === 7 || z === 2) c = c === GREY.base ? GREY.light : c; // the edges catch the light
}
set(x, y, z, c);
}
}import { draw } from "./assets/voxel";
import { jerseyBarrier } from "./assets/jersey-barrier";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, jerseyBarrier, x, y, { size: 64, angle: 0, t: performance.now() / 1000 });
// size: lo que mide en px su lado más largo
// angle: giro sobre el piso, en radianes
// t: segundos; si se mueve, se anima solo con eso# En una terminal, en la carpeta del juego
fogon assets add jersey-barrier
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["jersey-barrier"] })
# Queda en client/assets/jersey-barrier.ts
# https://fogon.gg/object/jersey-barrier