{"id":13741269,"url":"https://github.com/EvWilson/2jz","last_synced_at":"2025-05-08T21:33:01.891Z","repository":{"id":163504342,"uuid":"308224019","full_name":"EvWilson/2jz","owner":"EvWilson","description":"An archetype-based entity-component-system library written in Zig.","archived":true,"fork":false,"pushed_at":"2023-09-28T17:41:58.000Z","size":1209,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-06T13:57:57.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Zig","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/EvWilson.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}},"created_at":"2020-10-29T05:08:53.000Z","updated_at":"2025-03-21T05:17:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf21e3f9-81eb-4f87-9086-7d3564ecde25","html_url":"https://github.com/EvWilson/2jz","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/EvWilson%2F2jz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvWilson%2F2jz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvWilson%2F2jz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvWilson%2F2jz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvWilson","download_url":"https://codeload.github.com/EvWilson/2jz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253153163,"owners_count":21862318,"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":[],"created_at":"2024-08-03T04:00:57.361Z","updated_at":"2025-05-08T21:33:01.520Z","avatar_url":"https://github.com/EvWilson.png","language":"Zig","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# 2JZ\n\n## Hey!\nThanks for coming through and taking a look at this repo. As you might be able to tell, it's a good bit out of date and I don't really have any plans to maintain or update it at any point, so this is likely the last note I'll leave here. For those wanting to potentially make use of this in the future for whatever reason (likely me, wanting to demo to someone) the 0.7.0 release from https://ziglang.org/download/ seems to work for the Pong demo.\n\nAn archetype-based entity-component-system(ECS) library in Zig, inspired by\n[hecs](https://github.com/Ralith/hecs) and the many other delightful ECS\nlibraries of the world. I'd highly recommend reading the README there for more\nbackground on ECS in general.\n\n### Example\n\n```zig\nconst allocator = std.testing.allocator;\nconst expect = std.testing.expect;\n\nconst Position = struct { x: u32, y: u32 };\nconst HP = struct { points: u8, alive: bool };\n\n// Create a world from your component types\nvar world = try World.init(allocator, .{ Position, HP });\ndefer world.deinit();\n\n// Create entries with any combination of types\nvar entity = try world.spawn(.{Position{ .x = 5, .y = 7 }});\nvar entity2 = try world.spawn(.{ Position{ .x = 1, .y = 2 }, HP{ .points = 100, .alive = true } });\n\n// Query for all entries containing a Position\nvar query = try world.query(.{Position});\n\nwhile (query.next()) {\n    var position = query.dataMut(Position);\n    position.x *= 2;\n\n    const ent = query.entity();\n\n    // Prints both entities' Position information\n    if (world.remove(ent)) {\n        std.debug.print(\"removed entity: {}, with position: {}\\n\", .{ ent, position });\n    }\n}\n```\n\n### ECS in a Breath\nECS architecture is designed to make it easy to maintain loosely-coupled state\nand behavior for complex systems, while ideally not sacrificing in performance\nor developer ergonomics. Basically, entities are things, components are\ndescriptions of those things, and systems are ways to use and modify those\ndescriptions.\n\n### What's this archetype bit about?\nThe naive approach to this architecture might have you arrange your components\nin separate arrays of some kind, as seen in\n[this easy to follow jumping off point](https://austinmorlan.com/posts/entity_component_system/).\nHowever, this approach effectively kills your chances of pulling in all the\ninformation you need for a given system's operation in a minimal number of cache\nlines. The archetype helps to group your heterogeneous data together as densely\nas possible, allowing for efficient memory access and minimal need for the\ncross-referencing data structures you get otherwise.\n\n### Examples\nCheck out the examples directory to get a feel for what usage might look like in\npractice. At the time of writing, this includes a Pong game written with SDL,\nand is a great example of Zig's fantastic C integration story.\n\n### Acknowledgements\nI'd love to be able to take a moment to give a huge thank you to the Zig\ncommunity for being such an awesome bunch of helpful hackers and tinkerers.\nTuning into the many showcases and demos from that scene is what convinced me to\nkeep pushing with this project, and the Discord is an amazing place to pick up\non all sorts of systems programming tidbits and adventures.\n\nOf course, I also owe a good amount to the other open source ECS libraries of\nthe world, most notably hecs above, for providing helpful design pillars for me\nto see, ignore, and then realize later was in fact a much better way of doing\nthings.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEvWilson%2F2jz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEvWilson%2F2jz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEvWilson%2F2jz/lists"}