Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sam-ecs

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sam-ecs

A specialized entity component system

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Sam-ECS: Sam's entity component system

Simple but specialized entity component system. Currently work in progress

Installation

$ npm install --save sam-ecs

Usage (ES6)

import { Manager, Entity, Processor } from 'sam-ecs';

//manager creation
var manager = new Manager();

//empty entity creation
var entity = new Entity(manager);

// add component to entity
/* Each component has to have at a minimum a 'name' and
 * 'state' object
 */
entity.addComponent({name: 'Transform', state: {x: 0, y: 0}});

// processor definition
class RenderProcessor extends Processor {
  constructor(manager, name) {
    super(manager, name);
    
    /* every entity that contains a render component
     * will be given to this processor's update
     * function
     */
    this.components = new Set(['Render']);
  }

  // Called every time manager.update is called
  update(entities, manager) {
    for (var hash of entities) {
      var entity = manager.getEntity(hash);
      // render entity
    }
  }

  // Required, called by the manager
  getComponentNames() {
    return this.components;
  }
}

Keywords

FAQs

Package last updated on 16 Dec 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc