3 Serpentity is a simple entity framework inspired by Ash.
9 ## Instantiating an engine
11 var engine = Serpentity();
13 Add entities or systems:
15 engine.addEntity(entityFactory());
16 engine.addSystem(new GameSystem());
22 Remove entities or systems:
24 engine.removeEntity(entityReference);
25 engine.removeSystem(systemReference);
29 Entities are the basic object of Serpentity, and they do nothing.
31 var entity = new Serpentity.Entity();
33 All the behavior is added through components
35 ## Creating Components
37 Components define data that we can add to an entity. This data will
38 eventually be consumed by "Systems"
40 Class("PositionComponent").inherits(Serpentity.Component)({
47 You can add components to entities by using the add method:
49 entity.add(new PositionComponent());
52 Systems can refer to entities by requesting nodes.
56 Nodes are sets of components that you define, so your system can require
57 entities that always follow the API defined in the node.
59 Class("MovementNode").inherits(Serpentity.Node)({
61 position : PositionComponent,
62 motion : MotionComponent
66 You can then request an array of all the nodes representing entities
67 that comply with that API
69 engine.getNodes(MovementNode);
73 Systems are called on every update, and they use components through nodes.
75 Class("TestSystem").inherits(Serpentity.System)({
77 added : function added(engine){
78 this.nodeList = engine.getNodes(MovementNode);
80 removed : function removed(engine){
81 this.nodeList = undefined;
83 update : function update(dt){
84 this.nodeList.forEach(function (node) {
85 console.log("Current position is: " + node.position.x + "," + node.position.y);
93 Just run `engine.update(dt)` in your game loop :D
98 * Implement the ashteroids demo (Serpentoids)
99 * Actually check performance