Skip to content

Donorhan/JS-EntitySystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS - Entity System

An open source entity system in Javascript, what else? Feel free to contribute :)

How to

An example is available in the folder "examples".

 
// Create a world.
var world = new ES.World();

// Add systems.
world.addSystem( new DEMO.GameSystem() );
world.addSystem( new DEMO.LifeSystem() );
world.addSystem( new DEMO.PhysicSystem() );
world.addSystem( new DEMO.GraphicSystem() );

// Create a first entity.
{
    var entity = world.createEntity();
    entity.addComponent( new DEMO.HealthComponent(100) );
    entity.addComponent( new DEMO.PositionComponent( 2, 7 ) );
    entity.addComponent( new DEMO.SpriteComponent("picture.png") );
    entity.addComponent( new DEMO.VelocityComponent() );                   
}

// Create a second entity.
{
    var entity = world.createEntity();
    entity.addComponent( new DEMO.VelocityComponent() );
    entity.addComponent( new DEMO.PositionComponent(-2, -3) );
}

// Update the simulation. (In a real simulation, this part is inside a loop)
world.update(0.0);
 

About

An Entity System in Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages