/entity-system-js

ensy - A very simple Entity System for JavaScript

Primary LanguageJavaScriptMIT LicenseMIT

Entity System for JavaScript

JavaScript implementation of the Entity System model as described by Adam Martin in his blog post series Entity Systems are the future of MMOs.

Installation

Using bower:

bower install ensy

Using npm:

npm install ensy

Documentation

The documentation is available on Read the docs. All methods are well documented and parameters are described. If you are familiar with Entity Systems, it shouldn't be too hard to understand.

Here is a quick example:

require('entity-manager', function (EntityManager)) {
    var manager = new EntityManager();

    var Player = {
        name: 'Player',
        description: "The player's state",
        state: {
            life: 100,
            strength: 18,
            charisma: 3,
        }
    };

    manager.addComponent(Player.name, Player);
    var player = manager.createEntity(['Player']);
    var playerData = manager.getComponentDataForEntity('Player', player);
    playerData.life = 80;
}

Examples

There are examples in the examples directory:

For developers

Install the dependencies with npm install.

Running tests

$ npm test

To run the tests in your browser:

$ make test-browser

Building the documentation

$ npm run build_doc