dreki
v0.0.14
Published
π An Entity-Component System library written in Typescript
Readme
π dreki
An Entity-Component System (ecs) library written in Typescript.
π§ The package is a work-in-progress and might be unstable, use it at your own risks. π§
π Install
npm i drekiπ Example
import { World, query } from "dreki";
import { not } from "dreki/filters";
class Dead {}
class Position {
x: = 0;
y: = 0;
}
const alive = query(not(Dead), Position);
function aliveSystem() {
for (const [pos] of alive) {
// do something to alive entities ...
}
}
const world = World.build()
.with({ capacity: 200 })
.stageAfter(Stages.Update, "my_custom_stage")
.systems("my_custom_stage", aliveSystem)
.done();
const entity = world.spawn(Position);
const dead_entity = world.spawn(Position, Dead);
setInterval(() => {
world.update();
}, 1 / 60);π₯³ Getting started
TODO
