{"id":18554019,"url":"https://github.com/set001/ecsengine","last_synced_at":"2025-05-15T12:07:37.063Z","repository":{"id":57219387,"uuid":"138798110","full_name":"SET001/ecsengine","owner":"SET001","description":"Simple entity component system (ECS) engine for JavaScript","archived":false,"fork":false,"pushed_at":"2018-07-09T21:56:55.000Z","size":151,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T09:45:25.632Z","etag":null,"topics":["entity","entity-component"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SET001.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-26T21:58:40.000Z","updated_at":"2019-05-21T10:24:06.000Z","dependencies_parsed_at":"2022-08-29T02:12:10.237Z","dependency_job_id":null,"html_url":"https://github.com/SET001/ecsengine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SET001%2Fecsengine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SET001%2Fecsengine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SET001%2Fecsengine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SET001%2Fecsengine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SET001","download_url":"https://codeload.github.com/SET001/ecsengine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337606,"owners_count":22054254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["entity","entity-component"],"created_at":"2024-11-06T21:19:20.606Z","updated_at":"2025-05-15T12:07:32.047Z","avatar_url":"https://github.com/SET001.png","language":"TypeScript","readme":"\n*THIS LIBRARY IS CURRENTLY IN ACTIVE DEVELOPMENET, THINGS WILL SIGNIFICANTLY CHANGE IN NEAREST FUTURE!*\n\n# ecsengine\nSimple Entity-Component-System (ECS) engine for JavaScript written in TypeScript.\n\n# Install\n\n`npm install ecsengine --save`\n\n# Usage\n1. Create an instance of engine\n\n```TypeScript\nimport { Engine } from 'ecsengine'\nconst engine = new Engine()\n```\n\n2. Define your components. The components are just to store data. It does not have to contain any logic. According to ECS paradigm - you store all your logic in System's code.\n\n```TypeScript\nclass PositionComponent extends Component{\n  x: number = 0\n  y: number = 0\n  z: number = 0\n}\n\nclass PhysicComponent extends Component{}\n```\nComponent may be an empty class - just to point that entity with that component have some behavior.\n\n3. Define component group for system. Each system interested in work with entity that have some set of components.\n\n```TypeScript\nclass PhysicComponentGroup{\n  position: PositionComponent = new PositionComponent()\n  physic: PhysicComponent = new PhysicComponent()\n}\n```\n\n4. Define system and describe your logic there:\n\n```TypeScript\n@componentsGroup(PhysicComponent)\nclass PhysicSystem extends System\u003cPhysicComponentGroup\u003e{\n  execute(content: PhysicComponentGroup){\n    content.position.x -= 9.8\n  }\n}\n```\nAlso note that this code use decorators so you must have `\"experimentalDecorators\": true,` in your `tsconfig.json`\n\n5. Define class for your entity:\n```TypeScript\nclass GameObject extends Entity{\n  constructor(){\n    super()\n    this.add(PhysicComponent, {})\n    this.add(PositionComponent, {})\n  }\n}\n```\n\n6. Add system and entity to engine and run it:\n```TypeScript\nconst gameObject = new GameObject()\nengine.addSystem(PhysicSystem)\nengine.addEntity(gameObject)\n\nsetInterval(()=\u003e{\n  engine.update()\n  console.log(gameObject.components.get(PositionComponent))\n}, 100)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fset001%2Fecsengine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fset001%2Fecsengine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fset001%2Fecsengine/lists"}