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.

ECSpresso: ECS steam rising from a coffee cup beside the preso wordmarkECSpresso: ECS steam rising from a coffee cup beside the preso wordmark

The interactive quick start

Play a game. Change a system.

Change movement speed, explore component types,
and run your changes.

01 / The game

Bean Run

Collect & dodge
0 / 8 beans3 lives
Your browser needs canvas support to play Bean Run.
Move with WASD or ↑ ↓ ← →

Collect 8 beans. Dodge the sparks. Press Play to begin.

Pick up beans Avoid hot sparksThree lives. One cup.
02 / The code

Typed by design.

TS
movement.tsLoading TypeScript…
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.

Change speed: 160 to 240. Run, focus the game, and feel the difference. Explore suggestions inside the query and hover over position.

Take it into your project

Build your own game.

Zero core runtime dependencies.
Add rendering, input, and other plugins as you need them.

npm install ecspresso
Read the getting-started guide

Keep exploring

From a system to a game.

All examples