New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ecs-library

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecs-library

A full-featured Entity Component System library

latest
npmnpm
Version
1.0.5
Version published
Maintainers
0
Created
Source

ECS Library

A TypeScript Entity Component System (ECS) library for game development and simulation applications.

Features

  • Complete ECS Architecture: Entities, Components, Systems, and World management
  • Event System: Communication between systems and components
  • Spatial Partitioning: Efficient collision detection with QuadTree
  • Grid System: Grid-based movement and organization
  • Pathfinding: A* algorithm for finding paths in grid-based environments
  • State Machine: Finite state machine for entity behavior
  • Tweening: Smooth interpolation of component properties
  • Prefabs: Templates for efficient entity creation
  • Timers: Time-based events and actions
  • Game Components: Enhanced health, weapons, particles, pickups, and more
  • Behavior System: Modular AI patterns for entities
  • Wave Management: Tools for managing waves of enemies or events
  • Particle Effects: Particle emitters and visual effects

Installation

npm install ecs-library

Basic Usage

import * as ecs from 'ecs-library';

// Create a world
const world = new ecs.World();

// Add systems
world.addSystem(new ecs.MovementSystem());
world.addSystem(new ecs.CollisionSystem());

// Create an entity
const player = world.createEntity();
player.addComponent(new ecs.TransformComponent(100, 100));
player.addComponent(new ecs.VelocityComponent(0, 0));
player.addComponent(new ecs.ColliderComponent(32, 32));
player.addTag('player');

// Game loop
function gameLoop(deltaTime) {
  // Update the world
  world.update(deltaTime);
  
  // Request next frame
  requestAnimationFrame(gameLoop);
}

// Start the game loop
requestAnimationFrame(gameLoop);

Creating Custom Components

import { Component } from 'ecs-library';

class PlayerComponent extends Component {
  public score: number = 0;
  public lives: number = 3;
  
  constructor(score: number = 0, lives: number = 3) {
    super();
    this.score = score;
    this.lives = lives;
  }
  
  public clone(): PlayerComponent {
    const player = new PlayerComponent();
    player.score = this.score;
    player.lives = this.lives;
    return player;
  }
}

Creating Custom Systems

import { System } from 'ecs-library';
import { PlayerComponent } from './PlayerComponent';

class PlayerSystem extends System {
  public update(deltaTime: number): void {
    if (!this.world) return;
    
    const entities = this.world.getEntitiesWithComponent(PlayerComponent);
    
    for (const entity of entities) {
      const playerComponent = entity.getComponent(PlayerComponent);
      
      // Game logic here...
    }
  }
}

Documentation

For detailed documentation, see the ECS Library Documentation.

For API reference, see the API Reference.

Examples

Check out the examples directory for more usage examples:

License

MIT

Keywords

ecs

FAQs

Package last updated on 15 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts