← Kit de nivelesObjeto 3Dfogon/nivel-estrella
Estrella
Arrastrá para girarlo// «Estrella» · gpt-6-sol (medium)
// A chunky five-pointed golden star collectible standing upright, facing -y: about 32 across and 32 tall, one point straight up, two points touching near z 0 at the bottom, 6 blocks thick in the center and thinner toward the points (a puffy, beveled star). Bright yellow-gold with a lighter yellow front face, darker orange-gold edges, and two simple cute black eyes (2x4 blocks each) on the front. The whole star is one part that spins and bobs.
part("estrella", [24, 24, 16]);
const outline = [
[24, 35], [29.3, 23.3], [41.4, 23.5],
[32, 15], [35.4, -1], [24, 9],
[12.6, -1], [16, 15], [6.6, 23.5],
[18.7, 23.3]
];
function inside(px, pz) {
let hit = false;
for (let i = 0, j = outline.length - 1; i < outline.length; j = i++) {
const [xi, zi] = outline[i], [xj, zj] = outline[j];
if ((zi > pz) !== (zj > pz) &&
px < (xj - xi) * (pz - zi) / (zj - zi) + xi) hit = !hit;
}
return hit;
}
function edgeDistance(px, pz) {
let nearest = Infinity;
for (let i = 0; i < outline.length; i++) {
const [ax, az] = outline[i];
const [bx, bz] = outline[(i + 1) % outline.length];
const dx = bx - ax, dz = bz - az;
const t = Math.max(0, Math.min(1,
((px - ax) * dx + (pz - az) * dz) / (dx * dx + dz * dz)));
nearest = Math.min(nearest, Math.hypot(px - ax - t * dx, pz - az - t * dz));
}
return nearest;
}
for (let z = 0; z <= 35; z++) {
for (let x = 7; x <= 41; x++) {
if (!inside(x, z)) continue;
const distance = edgeDistance(x, z);
const half = Math.min(3, 1 + Math.floor(distance / 1.35));
const front = 24 - half;
const back = 23 + half;
for (let y = front; y <= back; y++) {
let color;
if (y === front) {
color = half === 3 ? "#ffe45a" :
half === 2 ? "#ffc83a" : "#e99a18";
if (half === 3 && z >= 23) color = "#ffeb74";
} else if (y === back) {
color = "#bc7516";
} else {
color = z < 10 ? "#d99019" : "#f2ad20";
}
set(x, y, z, color);
}
}
}
// Two little feet make the lower points meet the floor.
set(13, 24, 0, "#e9a01e");
set(35, 24, 0, "#e9a01e");
// Simple, chunky eyes on the viewer-facing side.
box(19, 20, 17, 20, 20, 20, "#171725");
box(27, 20, 17, 28, 20, 20, "#171725");
animate("estrella", { type: "spin", axis: "z", speed: -2 });
animate("estrella", { type: "bob", axis: "z", amplitude: 1.5 });import { draw } from "./assets/voxel";
import { nivelEstrella } from "./assets/nivel-estrella";
// En cada cuadro: parado sobre (x, y), el centro de su base.
draw(ctx, nivelEstrella, 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-estrella
# Con las herramientas de Fogón (conector)
add_assets({ slug: "<tu-juego>", ids: ["nivel-estrella"] })
# Queda en client/assets/nivel-estrella.ts
# https://fogon.page/object/nivel-estrella