An entity component system library for JavaScript
npm install --save ecsjs
<script type="application/javascript" src="./some-path/ecs.js"></script>
<script>
// define a component
class Position {
constructor(x, y) {
this.x = x
this.y = y
}
}
// register the component
ecs.register(Position)
// create an entity
const entityId = ecs.getNextId()
// add or update the entity data
ecs.set(entityId, new Position(25, 25))
</script>
import { ecs } from 'ecsjs'
// define a component
class Position {
constructor(x, y) {
this.x = x
this.y = y
}
}
// register the component
ecs.register(Position)
// create an entity
const entityId = ecs.getNextId()
// add or update the entity data
ecs.set(entityId, new Position(25, 25))
Licensed under GNU GPL v3
Copyright © 2013+ contributors