ecspresso
    Preparing search index...

    ecspresso v0.12.3

    ECSpresso

    (pronounced "ex-presso")

    A type-safe, modular, and extensible Entity Component System (ECS) framework for TypeScript and JavaScript.

    • Type-Safe: Full TypeScript support with component, event, and resource type inference
    • Modular: Plugin-based architecture for organizing features
    • Developer-Friendly: Clean, fluent API with method chaining
    • Event-Driven: Integrated event system for decoupled communication
    • Resource Management: Global state management with lazy loading
    • Asset Management: Eager/lazy asset loading with groups and progress tracking
    • Screen Management: Game state/screen transitions with overlay support
    • Entity Hierarchy: Parent-child relationships with traversal and cascade deletion
    • Query System: Powerful entity filtering with helper type utilities
    • System Phases: Named execution phases with fixed-timestep simulation
    • Change Detection: Per-system monotonic sequence change tracking with changed query filters
    • Reactive Queries: Enter/exit callbacks when entities match or unmatch queries
    • Command Buffer: Deferred structural changes for safe entity/component operations during systems
    npm install ecspresso
    
    import ECSpresso from 'ecspresso';

    // 1. Define your component types
    interface Components {
    position: { x: number; y: number };
    velocity: { x: number; y: number };
    health: { value: number };
    }

    // 2. Create a world using the builder — types are inferred automatically
    const world = ECSpresso.create()
    .withComponentTypes<Components>()
    .build();

    // 3. Add a movement system
    world.addSystem('movement')
    .addQuery('moving', { with: ['position', 'velocity'] })
    .setProcess((queries, deltaTime) => {
    for (const entity of queries.moving) {
    entity.components.position.x += entity.components.velocity.x * deltaTime;
    entity.components.position.y += entity.components.velocity.y * deltaTime;
    }
    });

    // 4. Create entities
    const player = world.spawn({
    position: { x: 0, y: 0 },
    velocity: { x: 10, y: 5 },
    health: { value: 100 }
    });

    // 5. Run the game loop
    world.update(1/60);

    MIT