eccy
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Eccy

npm

Yet Another ECS Library

Status

Very experimental, early development. You probably shouldn't use this for any real stuff just yet.

How to use

1. Define a component

A component can be any class.

// Define a component
@component()
class Position {
  public constructor(
    public x: number,
    public y: number,
  ) {}
}
2. Define some systems
class RenderSystem extends System {
  // Create your queries
  private positions = Query.entities()
    .select(Position)
    .query();

  public override run() {
    // Iterate over the query results
    for (let [position] of this.positions) {
      position.x++;
    }
  }
}

@system({ runOnce: true })
class StartupSystem extends System {
  public override run(cmd: Commands) {
    // Spawn a new entity with a component
    cmd.spawn(new Position(10, 12));
  }
}
3. Configure the engine
let engine = new Engine()
  .system(StartupSystem, RenderSystem)
  .finalise();
4. Ready, set, go!
await engine.run(60); // Try to run at 60 fps

Package Sidebar

Install

npm i eccy

Weekly Downloads

0

Version

0.0.5

License

LGPL-3.0-or-later

Unpacked Size

130 kB

Total Files

95

Last publish

Collaborators

  • woubuc