{"id":19219893,"url":"https://github.com/pvigier/ecs","last_synced_at":"2025-09-06T03:45:01.059Z","repository":{"id":133057578,"uuid":"195429597","full_name":"pvigier/ecs","owner":"pvigier","description":"A simple and easy to use entity-component-system C++ library","archived":false,"fork":false,"pushed_at":"2019-11-02T14:33:34.000Z","size":70,"stargazers_count":65,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-13T01:07:17.746Z","etag":null,"topics":["cpp","ecs","entity-component","entity-component-system","game-development","header-only","modern-cpp"],"latest_commit_sha":null,"homepage":"https://pvigier.github.io/2019/07/07/entity-component-system-part1.html","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pvigier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-05T15:14:58.000Z","updated_at":"2025-05-03T03:05:21.000Z","dependencies_parsed_at":"2023-03-10T15:54:27.062Z","dependency_job_id":null,"html_url":"https://github.com/pvigier/ecs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pvigier/ecs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2Fecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2Fecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2Fecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2Fecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pvigier","download_url":"https://codeload.github.com/pvigier/ecs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvigier%2Fecs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273854560,"owners_count":25180011,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cpp","ecs","entity-component","entity-component-system","game-development","header-only","modern-cpp"],"created_at":"2024-11-09T14:33:12.851Z","updated_at":"2025-09-06T03:45:01.033Z","avatar_url":"https://github.com/pvigier.png","language":"C++","readme":"# ecs\n\n[![Build Status](https://travis-ci.org/pvigier/ecs.svg?branch=master)](https://travis-ci.org/pvigier/ecs)\n[![codecov](https://codecov.io/gh/pvigier/ecs/branch/master/graph/badge.svg)](https://codecov.io/gh/pvigier/ecs)\n\n`ecs` is the [entity-component-system](https://en.wikipedia.org/wiki/Entity_component_system) library I have created for my game [Vagabond](https://pvigier.github.io/tag/vagabond).\n\n`ecs` aims to be:\n\n* easy to use\n* fast\n* lightweight\n* header only\n* implemented with modern C++ features (C++17)\n\n## Example\n\nFirstly, you should define some components:\n\n```cpp\nstruct Position : public Component\u003cPosition\u003e\n{\n    float x;\n    float y;\n};\n\nstruct Velocity : public Component\u003cVelocity\u003e\n{\n    float x;\n    float y;\n};\n```\n\nA component of type `T` must inherit `Component\u003cT\u003e`.\n\nNow, let us create an entity manager:\n\n```cpp\nauto manager = EntityManager();\n```\n\nNext, let us create an entity with both components:\n\n```cpp\nauto entity = manager.createEntity();\nmanager.addComponent\u003cPosition\u003e(entity);\nmanager.addComponent\u003cVelocity\u003e(entity);\n```\n\nFinally, we can use `getEntitySet` to query all entities that have both components and update their positions:\n\n```cpp\nauto dt = 1.0f / 60.0f;\nfor (auto [entity, components] : manager.getEntitySet\u003cPosition, Velocity\u003e())\n{\n    auto [position, velocity] = components;\n    // Update the position\n    position.x += velocity.x * dt;\n    position.y += velocity.y * dt;\n}\n```\n\nIt is that easy!\n\nIf you want more examples, look at the [examples](https://github.com/pvigier/ecs/tree/master/examples) folder.\n\n## Documentation\n\nI have written several articles on my blog describing the design of the library. They are available [here](https://pvigier.github.io/2019/07/07/entity-component-system-part1.html).\n\nOtherwise, just look at the [EntityManager.h](https://github.com/pvigier/ecs/blob/master/include/ecs/EntityManager.h) file, it is simple to understand.\n\n## License\n\nDistributed under the MIT License.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpvigier%2Fecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpvigier%2Fecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpvigier%2Fecs/lists"}