Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/therealsamf/sam-ecs
A specialized entity component system
https://github.com/therealsamf/sam-ecs
Last synced: 17 days ago
JSON representation
A specialized entity component system
- Host: GitHub
- URL: https://github.com/therealsamf/sam-ecs
- Owner: therealsamf
- Created: 2016-11-14T06:18:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-12T06:17:54.000Z (almost 8 years ago)
- Last Synced: 2024-11-21T08:13:44.009Z (about 1 month ago)
- Language: JavaScript
- Size: 124 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Sam-ECS: Sam's entity component system
============================Simple but specialized entity component system. Currently work in progress
Installation
```
$ npm install --save sam-ecs
```Usage (ES6)
```
import { Manager, Entity, Processor } from 'sam-ecs';//manager creation
var manager = new Manager();//empty entity creation
var entity = new Entity(manager);// add component to entity
/* Each component has to have at a minimum a 'name' and
* 'state' object
*/
entity.addComponent({name: 'Transform', state: {x: 0, y: 0}});// processor definition
class RenderProcessor extends Processor {
constructor(manager, name) {
super(manager, name);
/* every entity that contains a render component
* will be given to this processor's update
* function
*/
this.components = new Set(['Render']);
}// Called every time manager.update is called
update(entities, manager) {
for (var hash of entities) {
var entity = manager.getEntity(hash);
// render entity
}
}// Required, called by the manager
getComponentNames() {
return this.components;
}
}
```