czpg-ecs
Entity Component System architecture in javascript
Usage
npm i --save czpg-ecs
Struct
Context // Top level container for ECS Entity // Entity object Component // Component object System // System base class
Inject Component type
; { thisx = x; thisy = y; } const positionComId = Component;
Create Entity
; let entity = ; // add componentlet positionCom = entity;// or use contructor insteadlet positionCom = entity;// positionCom = { x: 1, y: 2 } // remove componententity;// or use constructor insteadentity;
Create System
; { // priority is 10, enable is true super 10 true ; } { // get group of entities with Position component let group = context; groupentities; } let positionSystem = ;
Create Context
let context = ; // add entitycontext; // remove entitycontext; // add systemconetxt; // remove systemcontext; // run systemscontext;
Run in local
// clone and move to directory
git clone https://github.com/PrincessGod/ecs.js.git
cd ecs.js
// install npm packages
npm i
// build
npm run build
// build minify version
npm run build-min
// develop
npm run dev
// lint
npm run lint
// test
npm test