starfall-core
v1.1.0
Published
Pure game core of STARFALL — logic and a surface-agnostic renderer. No dependencies, no terminal, no DOM.
Maintainers
Readme
starfall-core
The pure game core of STARFALL — a roguelite shmup. Logic and a renderer that writes to any surface offering four methods. No dependencies, no terminal, no DOM, no I/O.
The same code runs the SSH arcade at ssh -p 2222 invaders.m2-webvision.de and
the browser easter egg on m2-webvision.de.
Usage
import { createGame, newGame, update, draw, type Surface } from "starfall-core"
const game = createGame(46, 30) // columns, rows — at least 44x22
newGame(game)
update(game, 1 / 60, { left: false, right: true, fire: true, choose: 0 })
draw(game, surface)update() is pure apart from mutating the state you hand it, takes an
injectable random source, and never touches the clock — so a run is
reproducible from a seed.
The surface
interface Surface {
clear(bg?: Color): void
drawText(text: string, x: number, y: number, fg: Color, bg?: Color): void
fillRect(x: number, y: number, width: number, height: number, bg: Color): void
drawTextSub?(text: string, x: number, y: number, fg: Color, fx: number, fy: number): void
}A Color is a hex string. Coordinates are cells, not pixels.
drawTextSub is optional and carries the fractional part of a position. A
canvas can use it to move things smoothly between cells; a terminal, which only
has whole cells, leaves the method out and the renderer rounds instead.
Shipping format
TypeScript source, no build step. Bundlers need to be told to transpile it —
for Next.js that means transpilePackages: ["starfall-core"] plus
allowImportingTsExtensions in tsconfig.json.
MIT
