← ArmasObjeto 3Dfogon/sandbags
Bolsas de arena
Arrastrá para girarlo// «Bolsas de arena» · propio
// A low curved wall of stacked burlap sandbags, three rows high, bags staggered like bricks, tan with darker seams.
// A low curved wall of sandbags, three rows high, each bag over the joint of the two below (like bricks). The wall
// follows an arc that bulges towards the front; the top row is one bag short at the left end.
const TONES = [
{ top: "#e2c996", base: "#cfb07a", shade: "#b39460", dark: "#8f7446" },
{ top: "#d9bd86", base: "#c4a46c", shade: "#a88956", dark: "#866b40" },
{ top: "#e8d2a4", base: "#d6ba88", shade: "#bb9e6c", dark: "#977c50" },
];
const SEAM = "#6f5530";
const R = 34, CX = 23.5, CY = 54; // the arc
const LEN = 11, ROW = 6, DEPTH = 4, HALF = 22; // a bag: 11 long, 6 high, 8 deep; the wall: 44 along the arc
for (let x = 0; x < 48; x++)
for (let y = 0; y < 48; y++) {
const dx = x - CX, dy = CY - y;
const s = Math.atan2(dx, dy) * R, depth = Math.hypot(dx, dy) - R; // along the wall, and across it
if (Math.abs(s) > HALF || Math.abs(depth) > DEPTH + 0.3) continue;
for (let z = 0; z < 3 * ROW; z++) {
const row = Math.floor(z / ROW), w = z % ROW;
const q = s + HALF + (row % 2 ? LEN / 2 : 0);
const n = Math.floor(q / LEN), u = q - n * LEN;
if (row === 2 && n === 0) continue;
// Each bag is a cushion: thinner at its ends and at its top and bottom, with the corners rounded off. That leaves
// a groove between a bag and the next.
const end = Math.min(u, LEN - u, s + HALF, HALF - s) < 1, lip = w === 0 || w === ROW - 1;
if (end && lip) continue;
if (Math.abs(depth) > DEPTH - (end ? 1 : 0) - (lip ? 1 : 0) + 0.3) continue;
const T = TONES[(n * 2 + row) % 3];
let c = w === ROW - 1 ? T.top : w === 0 ? T.dark : w === 1 ? T.shade : w === ROW - 2 && rand() < 0.5 ? T.top : T.base;
if (end) c = w <= 1 ? T.dark : T.shade;
else if (rand() < 0.07) c = T.shade; // the weave
if (u >= 1.6 && u < 2.6 && w >= 1) c = SEAM; // the stitching near one end
set(x, y, z, c);
}
}import { draw } from "./assets/voxel";
import { sandbags } from "./assets/sandbags";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, sandbags, 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 sandbags
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["sandbags"] })
# Queda en client/assets/sandbags.ts
# https://fogon.gg/object/sandbags