https://github.com/dannyfritz/flock
🐦🐦🐦 A simple, but powerful ECS written in TypeScript.
https://github.com/dannyfritz/flock
ecs entity-component-system entitycomponentsystem gamedev typescript
Last synced: 3 months ago
JSON representation
🐦🐦🐦 A simple, but powerful ECS written in TypeScript.
- Host: GitHub
- URL: https://github.com/dannyfritz/flock
- Owner: dannyfritz
- License: mit
- Created: 2019-10-11T05:13:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-12-30T18:06:20.000Z (4 months ago)
- Last Synced: 2026-01-03T12:18:42.294Z (4 months ago)
- Topics: ecs, entity-component-system, entitycomponentsystem, gamedev, typescript
- Language: TypeScript
- Homepage: https://dannyfritz.github.io/flock-ecs
- Size: 6.14 MB
- Stars: 19
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

[](https://github.com/dannyfritz/flock-ecs/blob/master/LICENSE)
[](https://www.npmjs.com/package/flock-ecs)
An entity component system (ECS) created with TypeScript in mind.
## Features
* No dependencies
* Very good TypeScript typings
* Simple, but powerful API
* Designed for performance
* Struct of Arrays for storing entity component values
* Entities are queryable by:
* Component
* Absence of Component
* Added Entity
* Removed Entity
* Systems can have 1 or more queries
## [Roadmap](https://github.com/dannyfritz/flock-ecs/issues/1)
## Install
```sh
npm install flock-ecs
```
```ts
const flock = require("flock-ecs");
//or
import * as flock from "flock-ecs";
```
## Examples
### [Simple](./examples/simple)
```ts
import * as flock from 'flock-ecs';
const world = new flock.World();
const Position = new flock.Component(
() => ({
x: 0,
y: 0,
})
);
world.registerComponent(Position);
const logSystem = new flock.System(
(entities) => {
entities.forEach(entity => {
const position = entity.getComponent(Position)!;
console.log(`{ x: ${position.value.x}, y: ${position.value.y} }`);
});
},
[ Position ],
);
for (let i=0; i<10; i++) {
const entity = world.createEntity();
entity.addComponent(Position, { x: Math.random() * 100, y: Math.random() * 100 });
}
logSystem.run(world);
world.maintain();
```
### [Boids](./examples/boids)
## [API Docs](https://dannyfritz.github.io/flock-ecs/)
## Development
This repo uses Yarn workspaces, so make sure you're using yarn instead of npm.
To build the library in watch mode:
```sh
yarn workspace flock-ecs dev
```
And then to live build one of the examples, in another terminal:
```sh
yarn workspace boids start
```
To run tests:
```sh
yarn test
```
To run tests in watch mode:
```sh
yarn test:dev
```
## [Code of Conduct](./CODE_OF_CONDUCT.md)