ecs-observable/examples/tetris/components.ts

32 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineComponent } from "../../src/component";
// ── Board ────────────────────────────────────────────
/** The playfield grid (20 rows × 10 cols). 0 = empty, non-zero = color index. */
export const Board = defineComponent("board", {
grid: Array.from({ length: 20 }, () => new Uint8Array(10)) as Uint8Array[],
});
// ── Active piece ─────────────────────────────────────
export const Piece = defineComponent("piece", {
shape: [] as number[][],
color: 1,
x: 3,
y: 0,
});
// ── Score / state ────────────────────────────────────
export const Score = defineComponent("score", {
points: 0,
lines: 0,
level: 1,
});
export const GameOver = defineComponent("gameOver", {});
export const Paused = defineComponent("paused", {});
// ── Timing ───────────────────────────────────────────
export const TickTimer = defineComponent("tickTimer", {
accumulator: 0,
interval: 800, // ms between gravity ticks
});