← Kit de nivelesObjeto 3Dfogon/nivel-moneda
Moneda
Arrastrá para girarlo// «Moneda» · gpt-6-sol (medium)
// A big shiny gold coin standing upright, facing -y: a disc of radius 15 and 4 blocks thick (axis y), centered at x 24, with its lowest point touching z 0 (center about z 15). A raised 2-block rim in brighter gold, a recessed face in deeper gold, and a raised star emblem in the middle; a white-yellow highlight on the upper left of the rim. 3-4 shades of gold. The whole coin is one part that spins and bobs.
part("moneda", [24, 24, 15]);
const cx = 24;
const cz = 15;
const radius = 15;
function inStar(x, z) {
const points = [];
for (let i = 0; i < 10; i++) {
const a = Math.PI / 2 + i * Math.PI / 5;
const r = i % 2 === 0 ? 9 : 4.1;
points.push([cx + Math.cos(a) * r, cz + Math.sin(a) * r]);
}
let inside = false;
for (let i = 0, j = 9; i < 10; j = i++) {
const [xi, zi] = points[i];
const [xj, zj] = points[j];
if ((zi > z) !== (zj > z) &&
x < (xj - xi) * (z - zi) / (zj - zi) + xi) {
inside = !inside;
}
}
return inside;
}
// Four-block-thick body, with a deeper-gold recessed face.
for (let x = 9; x <= 39; x++) {
for (let z = 0; z <= 30; z++) {
const d = Math.hypot(x - cx, z - cz);
if (d > radius) continue;
for (let y = 22; y <= 25; y++) {
let color = "#efa923";
if (y === 22 || y === 25) {
color = z > 17 ? "#e5a022" : "#d9911b";
if (x < 21 && z > 17) color = "#efac29";
if (rand() < 0.025) color = "#e9a425";
} else if (d > 13.5) {
color = z > 15 ? "#f8bc36" : "#cf8518";
}
set(x, y, z, color);
}
// Narrow engraved circle just inside the raised rim.
if (d >= 10.7 && d < 11.25) {
const engraving = x < 24 && z > 15 ? "#ffd052" : "#b87919";
set(x, 22, z, engraving);
set(x, 25, z, engraving);
}
// Two-block raised rim on both faces.
if (d >= 12.15) {
const upperLeft = x <= 22 && z >= 21;
const glint = x >= 12 && x <= 20 && z >= 24 && d >= 13.3;
let rim = z >= 16 ? "#ffd044" : "#e7a321";
if (upperLeft) rim = "#ffdd63";
if (glint) rim = "#fff3a3";
if (d < 12.75) rim = "#f7b936";
for (const y of [20, 21, 26, 27]) {
set(x, y, z, rim);
}
}
}
}
// Soft dark-gold edging beneath the raised star.
for (let x = 14; x <= 34; x++) {
for (let z = 5; z <= 25; z++) {
if (Math.hypot(x - cx, z - cz) >= 11) continue;
if (!inStar(x, z) &&
(inStar(x - 1, z) || inStar(x + 1, z) ||
inStar(x, z - 1) || inStar(x, z + 1))) {
set(x, 22, z, "#ae7017");
set(x, 25, z, "#ae7017");
}
}
}
// Chunky five-point star, raised two blocks from the recessed face.
for (let x = 14; x <= 34; x++) {
for (let z = 5; z <= 25; z++) {
if (!inStar(x, z)) continue;
const edge = !inStar(x - 1, z) || !inStar(x + 1, z) ||
!inStar(x, z - 1) || !inStar(x, z + 1);
set(x, 21, z, "#d58d17");
set(x, 26, z, "#d58d17");
const gold = edge
? (x < cx && z > cz ? "#ffe16a" : "#e6a52b")
: (x < cx && z > cz ? "#ffeb83" : "#ffd34a");
set(x, 20, z, gold);
set(x, 27, z, gold);
}
}
animate("moneda", { type: "spin", axis: "z", speed: -2 });
animate("moneda", { type: "bob", axis: "z", amplitude: 1.5 });import { draw } from "./assets/voxel";
import { nivelMoneda } from "./assets/nivel-moneda";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, nivelMoneda, 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 nivel-moneda
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["nivel-moneda"] })
# Queda en client/assets/nivel-moneda.ts
# https://fogon.page/object/nivel-moneda