Flock
🐦🐦🐦 A simple, but powerful ECS written in TypeScript.
Install / Use
/learn @dannyfritz/FlockREADME

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
Install
npm install flock-ecs
const flock = require("flock-ecs");
//or
import * as flock from "flock-ecs";
Examples
Simple
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
API Docs
Development
This repo uses Yarn workspaces, so make sure you're using yarn instead of npm.
To build the library in watch mode:
yarn workspace flock-ecs dev
And then to live build one of the examples, in another terminal:
yarn workspace boids start
To run tests:
yarn test
To run tests in watch mode:
yarn test:dev
Code of Conduct
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Writing Hookify Rules
90.0kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
review-duplication
99.7kUse this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project best practices and shared utilities.
