|
1 | | -# Arcade2D |
| 1 | +# arcade2d |
2 | 2 |
|
3 | | -A monorepo for 2D game development tooling in TypeScript: a publishable game |
4 | | -engine, example games, and a self-contained dev server. |
| 3 | +**A 2D game engine for TypeScript.** arcade2d gives you a component-driven |
| 4 | +world model, prefab-based object spawning, and a batteries-included runtime for |
| 5 | +rendering, physics, audio, and input — built on the libraries you already |
| 6 | +reach for, with a fully-typed, thoroughly-documented API. |
5 | 7 |
|
6 | | -## Layout |
| 8 | +- **Website:** https://arcade2d.dev |
| 9 | +- **Demos:** https://arcade2d.dev/demos |
| 10 | +- **API reference:** https://arcade2d.dev/docs |
7 | 11 |
|
8 | | -``` |
9 | | -packages/ |
10 | | - engine/ @arcade2d/engine — published to npm (tsup, ESM + CJS + d.ts) |
11 | | - tsconfig/ shared TypeScript base configs (private) |
12 | | - eslint-config/ shared flat ESLint configs (private) |
13 | | -demos/ |
14 | | - simple-shooter/ example game consuming @arcade2d/engine, basic shapes (private) |
15 | | - dungeon-crawler/ example game consuming @arcade2d/engine, texture & sprite rendering (private) |
16 | | -apps/ |
17 | | - devserver/ |
18 | | - backend/ NestJS API/host (private) |
19 | | - frontend/ React + Vite editor UI (private) |
20 | | -docker/ |
21 | | - devserver.Dockerfile builds backend + frontend into a single image |
| 12 | +```bash |
| 13 | +npm install @arcade2d/engine |
22 | 14 | ``` |
23 | 15 |
|
24 | | -## Requirements |
| 16 | +## What it is |
25 | 17 |
|
26 | | -Node 22+. Yarn is pinned via Corepack (`packageManager` in the root |
27 | | -`package.json`) — run `corepack enable` once. |
| 18 | +arcade2d is the engine at the center of a longer-term engine + editor + |
| 19 | +dev-server vision. The engine itself is the part you install today: a small, |
| 20 | +strongly-typed core that organizes a game as a **`World` of `WorldObject`s**, |
| 21 | +each assembled from **composable components**, ticked through a single |
| 22 | +deterministic update loop. |
28 | 23 |
|
29 | | -## Common tasks |
| 24 | +The design goals: |
30 | 25 |
|
31 | | -``` |
32 | | -yarn install # install everything |
33 | | -yarn build # turbo build (engine -> consumers) |
34 | | -yarn typecheck # turbo typecheck |
35 | | -yarn lint # turbo lint |
36 | | -yarn test # turbo test |
37 | | -yarn demo:simple-shooter # run the simple-shooter demo (requires engine built once) |
38 | | -yarn demo:dungeon-crawler # run the dungeon-crawler demo (requires engine built once) |
39 | | -yarn devserver # run backend + frontend with hot reload |
40 | | -``` |
| 26 | +- **Composition over inheritance.** Behaviour is built by attaching components |
| 27 | + to world objects, not by deepening a class hierarchy. Components declare |
| 28 | + their dependencies and own their lifecycle, so systems stay decoupled. |
| 29 | +- **Prefabs as the unit of content.** Objects are described once as a prefab |
| 30 | + and spawned through the world, so "what a thing is" is separated from "when |
| 31 | + it exists." |
| 32 | +- **Wrap, don't reinvent.** The engine leans on best-in-class libraries for the |
| 33 | + hard parts and presents them through one coherent, pixel-native API rather |
| 34 | + than shipping a weaker home-grown version of each. |
| 35 | +- **The docs are the product.** Every public symbol carries thorough JSDoc and |
| 36 | + cross-links, surfaced in your editor and rendered to the |
| 37 | + [API reference](https://arcade2d.dev/docs). The engine is built to be learned |
| 38 | + from autocomplete. |
| 39 | +- **Strict by default.** The codebase runs under TypeScript's strictest |
| 40 | + settings and codifies every engine error behind an `ErrorCode`, so failure |
| 41 | + modes are part of the typed contract. |
| 42 | + |
| 43 | +## Built on |
| 44 | + |
| 45 | +| Concern | Building block | |
| 46 | +| --------- | ---------------------------------------------------------------------------------------------------------- | |
| 47 | +| Rendering | [PixiJS](https://pixijs.com) v8 — the scene graph, shapes, sprites, textures, and frame animation | |
| 48 | +| Physics | [Rapier](https://rapier.rs) (`rapier2d-compat`) — rigid bodies, colliders, and gravity, wired pixel-native | |
| 49 | +| Audio | The Web Audio API — sound effects and music over master and per-category volume buses | |
| 50 | +| Input | Keyboard and mouse state, sampled per tick | |
| 51 | + |
| 52 | +arcade2d's job is to bind these together behind the world/object/component |
| 53 | +model so you write game logic, not glue code. |
41 | 54 |
|
42 | | -## Dev server |
| 55 | +## Demos |
43 | 56 |
|
44 | | -The React frontend builds to static assets that the NestJS backend serves, so |
45 | | -the whole thing runs as **one process on one port**. In development the two run |
46 | | -separately and Vite proxies `/api` to Nest. |
| 57 | +Three demos exercise the engine end-to-end and double as living documentation |
| 58 | +of idiomatic arcade2d code. Play them in the browser, or read the source: |
47 | 59 |
|
48 | | -Run from a published image (single container): |
| 60 | +- **[Simple Shooter](https://arcade2d.dev/demos/simple-shooter)** — top-down |
| 61 | + shooter with player movement, prefab spawning, and a pile of zombies, |
| 62 | + rendered with basic shapes. |
| 63 | +- **[Dungeon Crawler](https://arcade2d.dev/demos/dungeon-crawler)** — texture |
| 64 | + and sprite rendering with a full tileset and animated characters. |
| 65 | +- **[Physics Playground](https://arcade2d.dev/demos/physics-playground)** — a |
| 66 | + Rapier-backed rigid-body sandbox of falling, colliding, stacking shapes. |
| 67 | + |
| 68 | +## Development |
| 69 | + |
| 70 | +This repository is a Yarn 4 workspaces monorepo orchestrated by Turborepo. |
| 71 | +The published engine lives in `packages/engine`; everything else is tooling, |
| 72 | +demos, and the marketing/docs site. |
49 | 73 |
|
50 | 74 | ``` |
51 | | -docker run -p 4000:4000 ghcr.io/<owner>/arcade2d-devserver:latest |
| 75 | +packages/ |
| 76 | + engine/ @arcade2d/engine — the published package (ESM + CJS + d.ts) |
| 77 | + tsconfig/ shared TypeScript base configs (private) |
| 78 | + eslint-config/ shared flat ESLint configs (private) |
| 79 | +demos/ |
| 80 | + simple-shooter/ shapes-based shooter (private) |
| 81 | + dungeon-crawler/ texture & sprite rendering (private) |
| 82 | + physics-playground/ Rapier rigid-body sandbox (private) |
| 83 | +apps/ |
| 84 | + website/ arcade2d.dev — marketing site + generated API reference |
| 85 | + devserver/ in-progress dev-server / editor surface |
| 86 | +docker/ |
| 87 | + devserver.Dockerfile builds backend + frontend into a single image |
52 | 88 | ``` |
53 | 89 |
|
54 | | -Build the image locally (from the repo root): |
| 90 | +**Requirements:** Node 22+. Yarn is pinned via Corepack — run `corepack enable` |
| 91 | +once. |
55 | 92 |
|
56 | | -``` |
57 | | -docker build -f docker/devserver.Dockerfile -t arcade2d-devserver . |
| 93 | +```bash |
| 94 | +yarn install # install everything |
| 95 | +yarn build # turbo build (engine -> consumers) |
| 96 | +yarn typecheck # turbo typecheck across all workspaces |
| 97 | +yarn lint # turbo lint |
| 98 | +yarn test # turbo test (Jest) |
| 99 | +yarn demo:simple-shooter # run a demo against freshly-built engine dist |
| 100 | +yarn demo:dungeon-crawler |
| 101 | +yarn demo:physics-playground |
| 102 | +yarn website # run the arcade2d.dev site locally |
| 103 | +yarn devserver # run the dev-server backend + frontend |
58 | 104 | ``` |
59 | 105 |
|
60 | 106 | ## Publishing |
61 | 107 |
|
62 | 108 | Only `@arcade2d/engine` is published to npm. Record changes with |
63 | 109 | `yarn changeset`, bump with `yarn version-packages`, then tag and publish a |
64 | 110 | GitHub Release — the `Release` workflow publishes to npm on `release: |
65 | | -published`. The dev server image is built and pushed to GHCR by the |
66 | | -`Dev Server Image` workflow. |
| 111 | +published`. The website deploys to Cloudflare from `apps/website`, and the dev |
| 112 | +server image is built and pushed to GHCR by the `Dev Server Image` workflow. |
| 113 | + |
| 114 | +## License |
| 115 | + |
| 116 | +[MIT](packages/engine/package.json) © Marty Wallace |
0 commit comments