1 Serpentity is a simple entity framework inspired by Ash.
7 ## Instantiating an engine
9 var engine = Serpentity();
11 Add entities or systems:
13 engine.addEntity(entityFactory());
14 engine.addSystem(new GameSystem());
20 Remove entities or systems:
22 engine.removeEntity(entityReference);
23 engine.removeSystem(systemReference);
27 Entities are the basic object of Serpentity, and they do nothing.
29 var entity = new Serpentity.Entity();
31 All the behavior is added through components
33 ## Creating Components
35 Components define data that we can add to an entity. This data will
36 eventually be consumed by "Systems"
38 Class("PositionComponent").inherits(Serpentity.Component)({
45 You can add components to entities by using the add method:
47 entity.add(new PositionComponent());
50 Systems can refer to entities by requesting nodes.
54 Nodes are sets of components that you define, so your system can require
55 entities that always follow the API defined in the node.
57 Class("MovementNode").inherits(Serpentity.Node)({
59 position : PositionComponent,
60 motion : MotionComponent
64 You can then request an array of all the nodes representing entities
65 that comply with that API
67 engine.getNodes(MovementNode);
71 Systems are called on every update, and they use components through nodes.
73 Class("TestSystem").inherits(Serpentity.System)({
75 added : function added(engine){
76 this.nodeList = engine.getNodes(MovementNode);
78 removed : function removed(engine){
79 this.nodeList = undefined;
81 update : function update(dt){
82 this.nodeList.forEach(function (node) {
83 console.log("Current position is: " + node.position.x + "," + node.position.y);
91 Just run `engine.update(dt)` in your game loop :D
96 * Implement the ashteroids demo (Serpentoids)
97 * Actually check performance