Headless falling-block engine. It installs no input listeners and never draws.
import { createGame } from 'blocks';
const game = createGame({
seed: 42,
onRender: (state, canvas) => renderBoard(state, canvas),
});
game.moveLeft();
game.hardDrop();
game.step(16);
const saved = game.getState();
const resumed = createGame({ state: saved });
const tPiece = game.pieces.T;
const iPiece = game.getPiece('I');Use setState() or setBoard() to configure scenarios. peekNextPiece(),
setNextPieces(), and spawnNextPiece() control piece sequencing. Call
start() only when a browser RAF loop is wanted; otherwise call step() and
render() yourself.