← Level pieces 23D assetfogon/nivel-rayo-de-velocidad
Rayo de velocidad
Drag to turn it// «Rayo de velocidad» · gpt-6-sol (medium)
// A speed power-up: a chunky zig-zag lightning bolt standing upright facing -y, about 36 tall and 22 wide, 5 thick, bright yellow with an orange outline and a white highlight streak, floating with its lowest point at z 4.
part("rayo", [24, 24, 22]);
// Chunky, five-block-thick lightning bolt. Its lowest block is at z = 0.
const outline = [
[22, 34], [34, 34], [26, 22], [35, 22],
[15, -1], [20, 16], [13, 16]
];
function inside(x, z) {
let hit = false;
for (let i = 0, j = outline.length - 1; i < outline.length; j = i++) {
const [xi, zi] = outline[i];
const [xj, zj] = outline[j];
if ((zi > z) !== (zj > z) &&
x < (xj - xi) * (z - zi) / (zj - zi) + xi) {
hit = !hit;
}
}
return hit;
}
function filled(x, z) {
return inside(x + 0.5, z + 0.5);
}
for (let z = 0; z <= 34; z++) {
for (let x = 13; x <= 35; x++) {
if (!filled(x, z)) continue;
const edge = !filled(x - 1, z) || !filled(x + 1, z) ||
!filled(x, z - 1) || !filled(x, z + 1);
for (let y = 22; y <= 26; y++) {
let color;
if (edge) {
color = y === 22 ? "#ff9b19" : "#e78312";
} else if (y === 22) {
color = z > 22 ? "#ffe43b" : "#ffd523";
} else {
color = y === 26 ? "#eeb625" : "#ffd22a";
}
set(x, y, z, color);
}
}
}
// White highlight on the viewer-facing side.
for (let z = 24; z <= 32; z++) {
const x = Math.round(25 - (32 - z) * 0.42);
if (filled(x, z) && filled(x - 1, z) && filled(x + 1, z))
set(x, 22, z, "#ffffff");
}
for (const [x, z] of [[26, 31], [27, 31], [26, 30]]) {
if (filled(x, z)) set(x, 22, z, "#fff9d1");
}
animate("rayo", { type: "spin", axis: "z", speed: -2 });
animate("rayo", {
type: "colors",
palette: ["#fff27a", "#ffd000", "#ffffff"],
pattern: "pulse",
glow: 0.7
});import { draw } from "./assets/voxel";
import { nivelRayoDeVelocidad } from "./assets/nivel-rayo-de-velocidad";
// Every frame: standing on (x, y), the centre of its base.
draw(ctx, nivelRayoDeVelocidad, 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 nivel-rayo-de-velocidad
# With Fogón's tools (connector)
add_assets({ slug: "<your-game>", ids: ["nivel-rayo-de-velocidad"] })
# It lands in client/assets/nivel-rayo-de-velocidad.ts
# https://fogon.page/object/nivel-rayo-de-velocidad