Glyph Arena
Small TypeScript building blocks for 2D browser games. New here? Build a game in 30 minutes goes from an empty folder to something you can play, with no assets. Each package is an independent workspace member with no runtime dependencies, so a game composes only the pieces it needs.
Each module below is a separate workspace member; @fogrexon/glyph-arena bundles all of them into a single ESM build. Inside this repository the modules are consumed through workspace:*.
Play it
Five samples and the API docs, published from this repository — open the links, nothing to install:
| Sample | What it is | Source |
|---|---|---|
| Pickup | Top-down collection: 8 gems in 60 s, three lives | examples/pickup-demo |
| Camp | A side-on duel in two rooms: three verbs, and enemies that take turns | examples/camp |
| March | Eleven guards on a 92-column road: fight each one, or roll through it — one minute, instant retry | examples/march |
| Parry | Dash into an enemy to parry it; 20 waves from a fixed script | examples/parry |
| Runner | Side-scrolling platformer: three levels, no randomness | examples/runner |
| API Docs | One page per package, and the front page this README becomes | docs/ |
Every row is checked against the deployment: each example declares its own page in package.json (glyphArenaPage), assemble-site.mjs publishes exactly those, and scripts/demo-links.test.mjs fails when the table and the declarations disagree in either direction.
Which name to import
Only @fogrexon/glyph-arena is meant for consumers. It bundles every module and re-exports their value exports flat, so a game imports one name instead of one per module (API page).
The @fogrexon/glyph-arena-* names are workspace-internal: they are not published on their own, so importing them from outside this repository will not resolve.
Packages
Generated from packages/ when the docs are built — do not edit this table by hand.
| Module | What it does | API |
|---|---|---|
glyph-arena-actions | Keyboard action bindings for Glyph Arena. | api |
glyph-arena-assets | Fetch-based asset loading with in-flight deduplication and success caching. | api |
glyph-arena-audio | Web Audio playback for Glyph Arena. | api |
glyph-arena-body | A platformer body for Glyph Arena: gravity, a run with acceleration, a jump with coyote time and an input buffer, and axis-separated collision against a solid test you supply. | api |
glyph-arena-camera | 2D camera state and world-to-screen view matrix for Glyph Arena. | api |
glyph-arena-chase | Whether a pursuer should be walking toward something, and which way. One pure call per frame: ``ts const chase = chaseTarget( { x: enemy.x, w: enemy.w, dir: enemy.dir }, { x: player.x, w: player.w }, { sightPx: 224, stepTolerancePx: 0 }, (dir) => stepAhead(enemy, dir), ); ` It returns { noticed, dir, distancePx, walkable } and does nothing else: no state, no speed, no dt`, no defaults. The ground is probed in the direction it is about to walk, so "the way it looks" and "the way it walks" cannot disagree. | api |
glyph-arena-collide | Axis-aligned bounding box overlap for Glyph Arena. | api |
glyph-arena-draw | Minimal 2D canvas drawing helpers for Glyph Arena. | api |
glyph-arena-ecs | Minimal entity-component storage for Glyph Arena. | api |
glyph-arena-gamepad | Polling gamepad snapshots for Glyph Arena. | api |
glyph-arena-input | Keyboard and pointer input snapshot for Glyph Arena. | api |
glyph-arena-loop | Injectable frame loop for Glyph Arena. | api |
glyph-arena-reset | One list of "put this back", run in the order it was written: ``ts const reset = createReset(); reset.add("player", () => { player = createBody(spawn, PLAYER_CONFIG); }); reset.add("commitClock", () => { lastCommitMs = -Infinity; }); reset.run(); // boot // … reset.run(); // retry — the same list, not a second one `` | api |
glyph-arena-scene | Hierarchical scene graph nodes for Glyph Arena. | api |
glyph-arena-screen | Screen space: the CSS box a canvas is laid out in, the bitmap it actually is, and the ratio between them. | api |
glyph-arena-tilemap | Tile maps as text, and the two questions a platformer asks of them: *what is in this box*, and *what am I standing on*. | api |
glyph-arena-timer | Tick-driven timer scheduling for Glyph Arena. | api |
glyph-arena-touch | On-screen controls: which zone a finger is on, whether it still counts as down, and how far a stick is pushed. | api |
glyph-arena-transform | 2D local transform storage and world-matrix composition for Glyph Arena. | api |
glyph-arena-tween | Tick-driven scalar tweening for Glyph Arena. | api |
Putting it together
import { createWorld, createLoop } from "@fogrexon/glyph-arena";
const world = createWorld();
const entity = world.spawn();
world.set(entity, "stats", { hp: 10 });
const loop = createLoop({
onFrame(time) {
// `time` is the tick time reported by the injected clock.
},
});
loop.start();
Each package's API doc (docs/api-*.md) lists its exports, options and edge cases; each package also has a README.md under packages/. The same pages are rendered to HTML and published at fogrexon.github.io/glyph-arena/docs.
Running a sample locally
Each page in the table above is a Vite build of one directory under examples/. For the pickup sample:
pnpm install
pnpm build
pnpm --filter @fogrexon/glyph-arena-pickup-demo dev
pnpm build is not optional here: a sample resolves @fogrexon/glyph-arena-* through each package's dist, so starting the dev server before the packages are built fails to resolve them. The other samples use the same command with their own package name (@fogrexon/glyph-arena-camp-demo, -parry-demo, -runner-demo).
Development
pnpm install
pnpm typecheck # no build needed: tsconfig `paths` maps packages to their src
pnpm build # required: dist is what npm, Pages and the gates below read
pnpm check:package-entry-points # package.json entry points must exist
pnpm typecheck:public-api # emitted declarations must keep the public API
pnpm smoke:pack-install # pack, install offline, import + strict tsc
pnpm test
CI (.github/workflows/ci.yml) runs the same gates in this order:
install → typecheck → build → check:package-entry-points → typecheck:public-api → smoke:pack-install → test
See CONTRIBUTING.md for the definition of done and the repository layout.
Repository layout
packages/— the modules plus the@fogrexon/glyph-arenaumbrella, each withsrc/,test/and aREADME.mdexamples/— the four samples in the table above:pickup-demo,camp,parry,runnerdocs/—api-*.md, one per packagefixtures/public-api/— type-only fixture that imports every package by name and checks the emitted declarationsscripts/— repository checks such ascheck-package-entry-points.mjsandsmoke-pack-install.mjs
API pages
One page per package.
- Build a game in 30 minutes
- @fogrexon/glyph-arena
- @fogrexon/glyph-arena-actions
- @fogrexon/glyph-arena-assets
- @fogrexon/glyph-arena-audio
- @fogrexon/glyph-arena-body
- @fogrexon/glyph-arena-camera
- @fogrexon/glyph-arena-chase
- @fogrexon/glyph-arena-collide
- @fogrexon/glyph-arena-draw
- @fogrexon/glyph-arena-ecs
- @fogrexon/glyph-arena-gamepad
- @fogrexon/glyph-arena-input
- @fogrexon/glyph-arena-loop
- @fogrexon/glyph-arena-reset
- @fogrexon/glyph-arena-scene
- @fogrexon/glyph-arena-screen
- @fogrexon/glyph-arena-tilemap
- @fogrexon/glyph-arena-timer
- @fogrexon/glyph-arena-touch
- @fogrexon/glyph-arena-transform
- @fogrexon/glyph-arena-tween