Sub-Engine: A Data-First 2D Game Engine

An AI-first TypeScript game engine built on a pure-data ECS core with an optional PixiJS rendering bridge, published to npm as @sub-engine/core and @sub-engine/pixi.

An AI-first TypeScript game engine built on a pure-data ECS core with an optional PixiJS rendering bridge, published to npm as @sub-engine/core and @sub-engine/pixi.

🧩 Sub-Engine: Games as Data, Not Classes

Sub-Engine started from a stubborn question: what does a game engine look like if its primary author is an AI coding agent? The answer is a 2D engine with no class hierarchy to memorise — entities are integers, components are flat JSON, and systems are pure functions of the form (registry, dt) => registry. Everything an agent (or a person) needs to generate a working game is data and a small, verifiable vocabulary.

What it is

  • @sub-engine/core — a headless engine with zero browser dependencies: a registry, runtime schema validation, built-in systems, a fixed-timestep game loop, and navigation.
  • @sub-engine/pixi — an optional rendering bridge over PixiJS: responsive containers, sprite loading, tilemaps and a debug overlay.
  • create-sub-engine — a CLI that scaffolds a new game with the contract-first structure the reference titles use.
  • Fifteen reference games — tower defence, RTS, RPG and management sims — that double as executable documentation for every feature.

Design decisions with scars behind them

The engine's rulebook reads like a set of post-mortems because it is one. A swarm game leaked roughly 180,000 GPU objects in thirty seconds because PixiJS's removeChild does not free GPU memory; the fix — mandatory destroy({ children: true }) — is now a constitution article, not a note in a changelog. A movement bug that made units travel "125 tiles per second" on a 30-tile map traced back to a missing timestep scale, so the engine now states its velocity convention explicitly: units per 16ms tick, converted from a familiar per-second value.

The architecture keeps two registry implementations behind one interface: a straightforward MapRegistry and a ColumnarRegistry built on typed arrays for bulk numeric work. Schema validation runs on every write, which is what turns "the agent typo'd a component field" from a silent bug into an immediate error. Simulation runs headless in Node, so game logic is testable without a browser.

Tech stack

TechnologyRole
TypeScriptStrict, ESM-first engine code
PixiJSRendering bridge (@sub-engine/pixi)
ViteReference-game dev server and builds
Vitest201 tests across core and renderer
npmPublished packages and CLI scaffolding

The result

Sub-Engine is public and installable — @sub-engine/core, @sub-engine/pixi and create-sub-engine are on npm under the MIT licence, with the source at github.com/Type-3-studio/sub-engine. It is research that escaped the lab: an experiment in what makes a codebase legible to machines, shipped as a tool humans can use today.

Project Details

Year

July 2026

Also known as

سب-إنجن: محرّك ألعاب ثنائي الأبعاد قائم على البيانات

Tags

Game EngineECSOpen SourceDeveloper Tools

Tech Stack

TypeScriptPixiJSViteVitestnpm

Achievements

  • Published to npm: @sub-engine/core, @sub-engine/pixi, create-sub-engine
  • 15 reference games acting as living documentation
  • 201 unit tests across the core and renderer

Start a project

Get in touch and let us help build your next project.

Start a conversation ابدأ المحادثة