{"id":22343897,"url":"https://github.com/miou-zora/worm","last_synced_at":"2026-04-30T00:33:25.906Z","repository":{"id":229486910,"uuid":"776833867","full_name":"Miou-zora/WoRm","owner":"Miou-zora","description":"An implementation in Rust \u0026 Bevy of a worm (or snake) entity which is inspired by Terraria's Worm (more precisely, The Devourer of Gods).","archived":false,"fork":false,"pushed_at":"2024-04-06T14:01:23.000Z","size":1314,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T11:27:53.028Z","etag":null,"topics":["algorithm","bevy","ecs","gamedev","poc","rust","terraria"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Miou-zora.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":"2024-03-24T15:21:55.000Z","updated_at":"2024-03-24T15:55:20.000Z","dependencies_parsed_at":"2024-03-30T22:26:30.107Z","dependency_job_id":"4ef86527-6ba5-4162-81a2-adb1b0d7758c","html_url":"https://github.com/Miou-zora/WoRm","commit_stats":null,"previous_names":["miou-zora/worm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miou-zora%2FWoRm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miou-zora%2FWoRm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miou-zora%2FWoRm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miou-zora%2FWoRm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Miou-zora","download_url":"https://codeload.github.com/Miou-zora/WoRm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245632425,"owners_count":20647193,"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":["algorithm","bevy","ecs","gamedev","poc","rust","terraria"],"created_at":"2024-12-04T09:06:55.982Z","updated_at":"2026-04-30T00:33:25.851Z","avatar_url":"https://github.com/Miou-zora.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WoRm\n\nThis project is an implementation in [Rust](https://www.rust-lang.org/fr) \u0026 [Bevy](https://bevyengine.org/) of a worm (or snake) entity which is inspired by Terraria's Worm (more precisely, [The Devourer of Gods](https://calamitymod.wiki.gg/wiki/The_Devourer_of_Gods)).\n\nThe worm is a chain of segments that follow the head segment.\n\n![img_1.png](assets/img.png)\n\nYes, it's a worm. Michael is a worm. Michael is awful and he's a worm.\nAnd now, Michael have a friend: SOLACE OF OBLIVION. Look at him:\n\n![SOO.gif](assets/SOO.gif)\n\n(He is so kawaii ne, like [the devourer of gods](https://www.youtube.com/watch?v=WpPORZMgkFE). Maybe he'll like devouring the devourer of god)\n\n- Michael come from the first (second try) implementation which use [array](#second-approach-worm-and-segments) method.\n- SOLACE OF OBLIVION is the second (third try) implementation which use [path](#and-the-fourth-approach-the-most-important) method.\n\nIt's my first project in [Rust](https://www.rust-lang.org/fr) and [Bevy](https://bevyengine.org/), so be indulgent. I'm open to any advice or suggestion.\nI've voluntarily leaved some comments (useful and useless).\n\n## How to run the project?\n\n### Prerequisites\n\n- [Rust](https://www.rust-lang.org/fr)\n- [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)\n\n### Run the project\n\n```\ncargo run\n```\n\n## How do I've implemented the worm?\n\n### First approach: linked list\n\nIn the file [worm_linked_list.rs](src/worm_linked_list.rs), I've tried to implement the worm as a linked list. Each segment has a reference to the next segment.\n\n```\n// Head is just a Tail with a Tag \nTail -\u003e Option\u003cTail\u003e\n```\n\n(It doesn't work at all)\n\n### Second approach: array\n\nIn the file [worm_array.rs](src/worm_array.rs), I've implemented the worm as a struct with a Vec of segments. I get the Worm struct and iterate over the segments to update their positions in correct order.\n\n```\nWorm -\u003e Vec\u003cEntity\u003e\n```\n\n### Maybe a third approach?\n\nI'm thinking about a third approach where the head and tails are separated. The head will emit an event when it moves and the tails will listen to this event to update their position. I don't know if it's a good idea.\n\n### And the fourth approach (the most important one)\n\nThe problem with the previous methods is that the update of the parts is not optimised in the context of an E.C.S. architecture: the update of the parts depends on the previous parts, and so we are obliged to update the parts of the worm all at once, in a loop.\n\nSo we have to update the parts in no particular order. This is quite a complex challenge, at least to obtain a result similar to the [Array](#second-approach-worm-and-segments) method.\n\nTo solve this, I thought of creating a path on which the parts could be updated without taking into account the position of the other parts. This path would be included in a \"Worm\" component. This \"Worm\" would then have children, each with an index allowing a reference to be obtained in the path of the worm.\n\nYou can look at [worm_path.rs](src/worm_path.rs) for more details.\n\n```\nWorm -\u003e Path (List of points (position), number max of points, and length of path)\n\nWorm \u003c-Parent/Child-\u003e WormPart\n\nWormPart -\u003e Id\n```\n\n## Inspired by\n\nFor Array:\n- https://github.com/bevyengine/bevy/issues/9228\n- https://mbuffett.com/posts/bevy-snake-tutorial/\n\nFor Path:\n- https://www.reddit.com/r/gamemaker/comments/5f02q3/how_can_i_make_a_worm_enemy_in_my_game/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiou-zora%2Fworm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiou-zora%2Fworm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiou-zora%2Fworm/lists"}