← Piratas y marObjeto 3Dfogon/cofre-con-oro
Cofre con oro
Arrastrá para girarlo// «Cofre con oro» · gpt-6-sol (medium)
// An open pirate treasure chest: dark brown wood with gold corner braces and a big gold lock, the lid open backwards, overflowing with shiny gold coins, a pearl necklace and a few red and green gems.
const wood = "#79401f";
const lightWood = "#a9652c";
const darkWood = "#4b2718";
const gold = "#f5b928";
const brightGold = "#ffe17a";
const shadowGold = "#b87817";
// Solid chest and dark, recessed opening.
box(6, 10, 0, 41, 36, 15, darkWood);
box(7, 10, 1, 40, 11, 15, lightWood);
box(7, 12, 1, 40, 35, 14, wood);
box(7, 10, 1, 40, 10, 15, lightWood);
box(9, 13, 11, 38, 33, 16, "#341e16");
box(10, 14, 11, 37, 32, 12, "#63401e");
// Chunky front planks, grooves, and weathered highlights.
for (const z of [4, 9, 14]) {
box(7, 9, z, 40, 10, z, darkWood);
box(10, 9, z + 1, 37, 9, z + 1, "#bc7837");
}
for (let i = 0; i < 105; i++) {
const x = 10 + Math.floor(rand() * 28);
const z = 2 + Math.floor(rand() * 13);
if (![4, 9, 14].includes(z))
set(x, 9, z, rand() < 0.55 ? "#b47335" : "#874921");
}
// Thick walls around the open top.
box(6, 10, 0, 9, 36, 17, wood);
box(38, 10, 0, 41, 36, 17, darkWood);
box(6, 10, 0, 41, 13, 17, lightWood);
box(6, 33, 0, 41, 36, 17, darkWood);
box(10, 10, 16, 37, 11, 17, shadowGold);
box(10, 10, 17, 37, 10, 17, brightGold);
for (const x of [6, 41]) {
box(x, 11, 17, x, 35, 17, gold);
box(x, 11, 18, x, 35, 18, brightGold);
}
box(10, 35, 17, 37, 35, 17, gold);
// Gold corner braces and bands.
for (const x of [6, 38]) {
box(x, 8, 1, x + 3, 10, 17, shadowGold);
box(x + 1, 8, 2, x + 2, 8, 16, gold);
box(x + 1, 8, 3, x + 1, 8, 15, brightGold);
}
for (const z of [1, 15]) {
box(7, 8, z, 40, 9, z + 1, shadowGold);
box(10, 8, z + 1, 37, 8, z + 1, gold);
}
for (const y of [12, 33]) {
box(6, y, 2, 7, y + 2, 16, gold);
box(40, y, 2, 41, y + 2, 16, shadowGold);
}
// Big, unmistakable front lock.
box(19, 7, 8, 28, 9, 17, shadowGold);
box(20, 6, 9, 27, 7, 16, gold);
box(21, 5, 10, 26, 6, 15, brightGold);
box(23, 4, 12, 24, 5, 14, "#463019");
set(23, 4, 11, "#463019");
set(24, 4, 11, "#463019");
for (const x of [11, 36])
for (const z of [3, 12])
set(x, 8, z, brightGold);
// Overflowing pile of coins: its whole surface glitters.
part("coins", [24, 23, 17]);
ellipsoid(24, 23, 16, 14, 9, 7, gold);
ellipsoid(24, 23, 19, 11, 7, 5, "#ffd348");
for (let i = 0; i < 95; i++) {
const x = 11 + Math.floor(rand() * 27);
const y = 15 + Math.floor(rand() * 17);
const d = ((x - 24) / 14) ** 2 + ((y - 23) / 9) ** 2;
if (d > 0.92) continue;
const z = Math.floor(19 + 5 * Math.sqrt(1 - d));
cylinder(x, y, z, rand() < 0.3 ? 2 : 1, 1,
rand() < 0.5 ? brightGold : shadowGold, "z");
}
animate("coins", {
type: "colors",
palette: ["#e9a820", "#f9c63c", "#ffe276", "#ffd04b"],
pattern: "flicker",
glow: 0.3
});
part("body");
// Pearl necklace draped from the treasure over the front edge.
const necklace = [
[14, 20, 22], [16, 17, 22], [18, 14, 20], [19, 11, 18],
[21, 9, 16], [23, 8, 15], [25, 8, 15], [27, 9, 16],
[29, 11, 18], [31, 14, 20], [33, 17, 22], [35, 20, 22]
];
for (let i = 0; i < necklace.length - 1; i++) {
const a = necklace[i], b = necklace[i + 1];
line(a[0], a[1], a[2], b[0], b[1], b[2], 0, "#d7b98c");
}
for (const [x, y, z] of necklace) {
sphere(x, y, z, 1.25, "#fff4d9");
set(x, y - 1, z + 1, "#ffffff");
}
// Large faceted rubies and emeralds amid the gold.
function gem(x, y, z, main, shine, shade) {
box(x - 2, y - 1, z, x + 2, y + 1, z + 2, shade);
box(x - 1, y - 2, z + 1, x + 1, y + 2, z + 3, main);
box(x - 1, y - 1, z + 4, x + 1, y + 1, z + 4, shine);
set(x - 1, y - 2, z + 3, shine);
}
gem(14, 24, 21, "#e53e40", "#ff9290", "#a72032");
gem(33, 23, 21, "#19b86c", "#81f6a4", "#087d4f");
gem(29, 30, 21, "#d83246", "#ff7978", "#941b37");
// Gold hinge pins where the open lid meets the back wall.
for (const x of [11, 34]) {
cylinder(x, 36, 17, 2, 4, shadowGold, "x");
set(x, 34, 18, brightGold);
}
// Lid stands open behind the treasure, leaning backwards.
part("lid", [24, 36, 17]);
for (let z = 18; z <= 35; z++) {
const y = 36 + Math.floor((z - 18) * 0.36);
box(6, y, z, 41, y + 2, z, darkWood);
box(8, y - 1, z, 39, y, z,
z % 5 === 0 ? "#57301b" : z % 5 === 1 ? "#b77837" : "#935326");
// Broad gold frame on the inside of the lid.
if (z <= 20 || z >= 33) {
box(6, y - 2, z, 41, y - 1, z, gold);
box(8, y - 2, z, 39, y - 2, z, brightGold);
}
for (const x of [6, 7, 40, 41])
set(x, y - 2, z, x === 7 || x === 40 ? brightGold : shadowGold);
}
// A simple ivory pirate skull displayed inside the lid.
for (let z = 24; z <= 31; z++) {
const y = 36 + Math.floor((z - 18) * 0.36) - 2;
if (z >= 27) box(21, y - 1, z, 27, y - 1, z, "#fff2cc");
else box(23, y - 1, z, 25, y - 1, z, "#fff2cc");
if (z === 29) {
box(22, y - 2, z, 23, y - 2, z, "#3b2922");
box(25, y - 2, z, 26, y - 2, z, "#3b2922");
}
if (z === 27) set(24, y - 2, z, "#3b2922");
if (z === 24) {
set(23, y - 2, z, "#6c4935");
set(25, y - 2, z, "#6c4935");
}
}
animate("lid", { type: "swing", axis: "x", speed: 1.5, amplitude: 0.1 });import { draw } from "./assets/voxel";
import { cofreConOro } from "./assets/cofre-con-oro";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, cofreConOro, 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 cofre-con-oro
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["cofre-con-oro"] })
# Queda en client/assets/cofre-con-oro.ts
# https://fogon.page/object/cofre-con-oro