← Pirates and sea3D assetfogon/pila-de-monedas
Pila de monedas
Drag to turn it// «Pila de monedas» · gpt-6-sol (medium)
// A loose heap of shiny gold coins on the ground with a few coin stacks standing up, two red rubies and a golden goblet on top.
const gold = "#e8a91f";
const goldLight = "#ffd34d";
const goldBright = "#fff18a";
const goldShadow = "#ad6815";
part("coins", [24, 24, 0]);
// A broad, uneven mound of treasure.
ellipsoid(24, 24, 2, 19, 15, 5, goldShadow);
ellipsoid(24, 24, 4, 18, 14, 5, gold);
ellipsoid(23, 24, 7, 14, 11, 5, "#f2bc31");
ellipsoid(25, 25, 9, 9, 8, 4, gold);
forEach((x, y, z) => {
if (get(x, y, z + 1) !== undefined) return;
const n = rand();
if (n < 0.17) set(x, y, z, goldBright);
else if (n < 0.43) set(x, y, z, goldLight);
});
function topAt(x, y) {
for (let z = 22; z >= 0; z--) {
if (get(x, y, z) !== undefined) return z;
}
return 0;
}
function coin(x, y, z, r) {
cylinder(x, y, z, r, 1, goldShadow);
cylinder(x, y, z + 1, r, 1, goldLight);
// Chunky raised rim and a little stamped gleam.
for (let a = 0; a < 8; a++) {
const t = a * Math.PI / 4;
set(
x + Math.round(r * Math.cos(t)),
y + Math.round(r * Math.sin(t)),
z + 1,
a < 4 ? goldBright : gold
);
}
line(x - 1, y - 1, z + 2, x + 1, y - 1, z + 2, 0, goldBright);
}
// Loose coins overlap naturally across the sloped heap.
for (let i = 0; i < 105; i++) {
const a = rand() * Math.PI * 2;
const d = Math.sqrt(rand());
const x = Math.round(24 + Math.cos(a) * d * 17);
const y = Math.round(24 + Math.sin(a) * d * 13);
coin(x, y, topAt(x, y), rand() < 0.3 ? 2 : 3);
}
// Three upright, slightly uneven stacks.
function stack(x, y, bottom, count) {
for (let i = 0; i < count; i++) {
const sx = x + (i > 4 && i % 4 === 0 ? 1 : 0);
cylinder(sx, y, bottom + i * 2, 3, 1, goldShadow);
cylinder(sx, y, bottom + i * 2 + 1, 3, 1, goldLight);
line(sx - 2, y - 2, bottom + i * 2 + 1,
sx + 1, y - 2, bottom + i * 2 + 1, 0, goldBright);
}
cylinder(x, y, bottom + count * 2, 2, 1, goldBright);
}
stack(12, 24, 3, 7);
stack(36, 27, 3, 8);
stack(30, 36, 2, 6);
animate("coins", {
type: "colors",
palette: ["#d99118", "#edac22", "#ffd047", "#fff098"],
pattern: "flicker",
glow: 0.4
});
part("body", [24, 22, 15]);
// A golden goblet rising above the coins.
cylinder(24, 22, 12, 5, 2, goldShadow);
cylinder(24, 22, 14, 5, 1, goldBright);
cylinder(24, 22, 15, 3, 2, gold);
cylinder(24, 22, 17, 2, 6, goldLight);
line(23, 20, 18, 23, 20, 22, 0, goldBright);
for (let z = 23; z <= 29; z++) {
const r = z < 25 ? z - 20 : z < 27 ? 5 : 6;
cylinder(24, 22, z, r, 1, z % 2 ? gold : goldLight);
set(23, 22 - r, z, goldBright);
set(24, 22 - r, z, goldBright);
}
cylinder(24, 22, 30, 7, 1, goldBright);
cylinder(24, 22, 30, 5, 1, "#9b5916");
cylinder(24, 22, 29, 4, 1, "#c88920");
for (let a = 0; a < 24; a++) {
const t = a * Math.PI / 12;
set(24 + Math.round(7 * Math.cos(t)),
22 + Math.round(7 * Math.sin(t)), 31,
a % 3 === 0 ? "#fff4a1" : goldLight);
}
// Broad curled handles make the cup's silhouette unmistakable.
for (const s of [-1, 1]) {
line(24 + s * 5, 22, 28, 24 + s * 9, 22, 29, 1, goldBright);
line(24 + s * 9, 22, 29, 24 + s * 10, 22, 26, 1, gold);
line(24 + s * 10, 22, 26, 24 + s * 7, 22, 23, 1, goldLight);
line(24 + s * 7, 22, 23, 24 + s * 4, 22, 24, 1, gold);
}
// Two large faceted red rubies resting at the front.
function ruby(x, y, base) {
cylinder(x, y, base, 3, 1, "#741f26");
for (let dz = 1; dz <= 6; dz++) {
const r = dz <= 2 ? 3 : dz <= 4 ? 2 : 1;
for (let dx = -r; dx <= r; dx++) {
for (let dy = -r; dy <= r; dy++) {
if (Math.abs(dx) + Math.abs(dy) > r + 1) continue;
let color = dx < 0 ? "#ff5150" : "#b91c35";
if (dy < 0) color = dx < 0 ? "#ff7770" : "#e52d40";
if (dz === 6) color = "#ff9a87";
set(x + dx, y + dy, base + dz, color);
}
}
}
line(x - 1, y - 2, base + 3, x, y - 2, base + 5, 0, "#ffd0ab");
}
ruby(16, 14, topAt(16, 14));
ruby(34, 16, topAt(34, 16));import { draw } from "./assets/voxel";
import { pilaDeMonedas } from "./assets/pila-de-monedas";
// Every frame: standing on (x, y), the centre of its base.
draw(ctx, pilaDeMonedas, 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 pila-de-monedas
# With Fogón's tools (connector)
add_assets({ slug: "<your-game>", ids: ["pila-de-monedas"] })
# It lands in client/assets/pila-de-monedas.ts
# https://fogon.page/object/pila-de-monedas