32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
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
|
||
});
|