ecsjs
Version:
An entity component system library for JavaScript
77 lines (54 loc) • 1.82 kB
Markdown
//gitlab.com/ecsjs/ecs/badges/master/pipeline.svg)](https://gitlab.com/ecsjs/ecs/-/pipelines)
[](https://www.npmjs.org/package/ecsjs)
[](https://npmjs.org/package/ecsjs "View this project on NPM")
[](https://www.buymeacoffee.com/peterf)
An entity component system library for JavaScript
`npm install --save ecsjs`
- [Cheat Sheet](https://gitlab.com/ecsjs/ecs/-/blob/master/docs/cheat-sheet.md)
- [Reference Documentation](https://ecsjs.gitlab.io/ecs)
- [Classic Asteroids](https://gitlab.com/ecsjs/example-astroids)
- [Classic Kung Fu](https://gitlab.com/ecsjs/example-kungfu)
- [Misc Examples](https://gitlab.com/ecsjs/ecs-examples)
```html
<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>
```
```js
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](https://gitlab.com/ecsjs/ecs/-/graphs/master)
[![Pipeline status](https: