{"id":20550339,"url":"https://github.com/dnmfarrell/libentity","last_synced_at":"2026-07-22T15:32:24.876Z","repository":{"id":149703767,"uuid":"421646473","full_name":"dnmfarrell/libentity","owner":"dnmfarrell","description":"C doubly linked list for managing game entities","archived":false,"fork":false,"pushed_at":"2021-10-27T02:09:47.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T09:45:17.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","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/dnmfarrell.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-27T02:08:39.000Z","updated_at":"2021-10-27T02:09:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"91a2e694-5c10-4bb8-a9ce-9c6f51047eda","html_url":"https://github.com/dnmfarrell/libentity","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dnmfarrell/libentity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Flibentity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Flibentity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Flibentity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Flibentity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnmfarrell","download_url":"https://codeload.github.com/dnmfarrell/libentity/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnmfarrell%2Flibentity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35768236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-22T02:00:06.236Z","response_time":124,"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":[],"created_at":"2024-11-16T02:24:29.472Z","updated_at":"2026-07-22T15:32:24.850Z","avatar_url":"https://github.com/dnmfarrell.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"entity.h\n--------\nA minimalist entity management library, using a doubly linked list.\n\ntest.c\n------\nRun the test suite:\n\n    make test\n\nCheck for memory leaks (requires valgrind):\n\n    make mem\n\nexample.c\n---------\nYou can use `entity.h` to manage all the entities in a game. Imagine we have a simple fighter class:\n\n```c\n#include \u003cstdlib.h\u003e\n\ntypedef struct Fighter {\n  int hp;\n} Fighter;\n\nFighter* FighterNew() {\n  Fighter* f = malloc(sizeof(Fighter));\n  f-\u003ehp = 3;\n  return f;\n}\n\nint FighterUpdate (void* object) {\n  Fighter* f = object;\n  return f-\u003ehp--;\n}\n\nvoid FighterRender (void* object) {\n  // no graphics for now :-(\n}\n\nvoid FighterUnload (void* object) {\n  free(object);\n}\n```\n\nWe can call `EntityAdd` to add an object to an entity list. An entity can be any pointer, as long as it has update, render and unload methods.\n\n```c\n#include \"entity.h\"\n\nint main(void) {\n  Fighter* f = FighterNew();\n  Entity* entities =\n    EntityAdd(f, FighterUpdate, FighterRender, FighterUnload, NULL);\n\n  while (1) {\n    EntityUpdateAll(entities);\n    EntityUnloadDone(entities);\n    EntityRenderAll(entities);\n  }\n  // unload any remaining entities\n  EntityUnloadAll(entities);\n\n  return 0;\n}\n```\n\nEvery frame the game updates all entities by calling `EntityUpdateAll`. This calls every entity's `update` method, passing the object as the argument. Any entity whose update returns zero is marked as \"done\". Then `EntityUnloadDone` unloads all complete entities. Separating update and unload allows entities all entities to behave as if they're updating at the same time. `EntityRenderAll` renders the entities. Finally once the game ends, any remaining entities are removed with `EntityUnloadAll`.\n\nLicense\n-------\nCopyright 2021 David Farrell\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnmfarrell%2Flibentity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnmfarrell%2Flibentity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnmfarrell%2Flibentity/lists"}