ecstasy
v0.1.0
Published
A fast Entity-Component-System framework
Downloads
5
Maintainers
Readme
ecstasy
A fast Entity-Component-System framework for Javascript.
Additonally it supports Action and Turns - it's really useful when you're making turn based strategy game or multiplayer game.
Documentation
You can find quick reference here. You can find jsdoc documentation here.
Examples
Simple Example
var Engine = require('ecstasy').Engine;
var engine = new Engine();
// Define components
engine.c('pos', function PositionComponent(options) {
this.x = options.x || 0;
this.y = options.y || 0;
});
engine.c('vel', function VelocityComponent(options) {
this.x = options.x || 0;
this.y = options.y || 0;
});
// Define systems
engine.s('vel', {
add: function(engine) {
this.engine = engine;
this.entities = engine.e('pos', 'vel');
},
update: function(delta) {
this.entities.forEach(function(entity) {
entity.c('pos').x += entity.c('vel').x;
entity.c('pos').y += entity.c('vel').y;
});
}
});
// Define entities
engine.e({
pos: {x: 200, y: 200},
vel: {x: 3, y: 3}
});
setInterval(function() {
engine.update(12);
}, 12);