An ECS for TypeScript v0.24.1
Strong types.
Small ingredients.
A type-safe Entity Component System for TypeScript games.
Compose gameplay from plain data and small systems,
with autocomplete and component types inferred from your queries.
Play, edit, and run TypeScript in your browser. No setup required.
Zero core runtime dependencies. Optional plugins for input, rendering, physics, and more.
The interactive quick start
Play a game. Change a system.
Change movement speed, explore component types,
and run your changes.
Bean Run
Collect 8 beans. Dodge the sparks. Press Play to begin.
Typed by design.
world.addSystem('movement')
.withResources(['input', 'settings', 'game'])
.addQuery('moving', {
with: ['position', 'velocity'],
mutates: ['position'],
})
.setProcess(({ queries, resources, dt }) => {
queries.moving.forEach(entity => {
if (resources.game.phase !== 'playing') return;
const { position } = entity.components;
position.x = Math.max(18, Math.min(622,
position.x + resources.input.x * resources.settings.speed * dt));
position.y = Math.max(18, Math.min(342,
position.y + resources.input.y * resources.settings.speed * dt));
});
});Loading the editor…
You can edit the game here shortly.
Edit the code, then Run changes. Ctrl / ⌘ Enter also runs.
Inspect a type to see what TypeScript knows.
Types check out
No TypeScript errors.
Change speed: 160 to 240. Run, focus the game, and feel the difference. Explore suggestions inside the query and hover over position.
Keep exploring