🌌 ModECS 🌌
Small, fast, data-oriented, runtime-composable ECS library written in JavaScript.
Features
- ~5 KB gzipped
- Classless ES6
- Performance focused
- Runtime composable
- Promotes reusability
Planned
Install
npm i modecs
Example
const ModECS = require('modecs')
const engine = ModECS()
engine.registerComponent('POSITION', { x: 0, y: 0 })
engine.registerComponent('TARGET', { x: 0, y: 0 })
engine.registerSystem(
'Movement',
['POSITION','TARGET'],
() => {
const speed = 10
return (position, target, entityId) => {
position.x += target.x * speed * engine.time.delta
position.y += target.y * speed * engine.time.delta
}
}
)
const entityID1 = engine.createEntity()
engine.addEntity(entityID1)
const entityID2 = engine.createEntity()
engine.addEntity(entityID2)
engine.addComponent(entityID2, 'POSITION', { x: 50 })
engine.addComponent(entityID2, 'TARGET', { x: 1, y: 1 })
engine.start()
Check out the Introduction for more details.