Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaforbes/e
A Javascript Entity Component System Library
https://github.com/jaforbes/e
Last synced: about 1 month ago
JSON representation
A Javascript Entity Component System Library
- Host: GitHub
- URL: https://github.com/jaforbes/e
- Owner: JAForbes
- License: mit
- Created: 2014-08-22T11:29:30.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-15T06:20:30.000Z (almost 10 years ago)
- Last Synced: 2024-04-16T09:06:36.712Z (7 months ago)
- Language: JavaScript
- Size: 266 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
e
=A Javascript Entity Component System Library
Dependencies:
- [Underscore.js](https://github.com/jashkenas/underscore)
```javascript
//Create linked components
var id = E({
Position: {x:0 , y:0},
Collideable: {},
//Anything else you want
})//Add additional components later
E(id,'Velocity',{x:1,y:0})//Query all of a type and use them in systems
function move(){
E('Velocity').each(function(velocity,entityID){
//grab components with the same id
var pos = E('Position',entityID);
pos.x += velocity.x
pos.y += velocity.y
})}
//Access everything
E() //returns the entire structure, because everything should be hackable//Delete component
delete E().Position[id]//Delete all components of a type
delete E().Position```