{"id":18498210,"url":"https://github.com/hugo-dz/rust-sandbox","last_synced_at":"2025-09-14T20:27:13.690Z","repository":{"id":205042963,"uuid":"686620276","full_name":"Hugo-Dz/rust-sandbox","owner":"Hugo-Dz","description":"🦖 A tiny sandbox game written in Rust using Bevy","archived":false,"fork":false,"pushed_at":"2024-03-08T12:15:13.000Z","size":6884,"stargazers_count":74,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-23T19:44:48.462Z","etag":null,"topics":["bevy","game-development","game-engine","gamedev","rust"],"latest_commit_sha":null,"homepage":"https://rust-sandbox.vercel.app","language":"JavaScript","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/Hugo-Dz.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-09-03T12:04:38.000Z","updated_at":"2025-03-21T06:25:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"8056b68b-b658-43e8-a1cd-8341884495cd","html_url":"https://github.com/Hugo-Dz/rust-sandbox","commit_stats":null,"previous_names":["hugo-dz/rust-sandbox"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugo-Dz%2Frust-sandbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugo-Dz%2Frust-sandbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugo-Dz%2Frust-sandbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugo-Dz%2Frust-sandbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hugo-Dz","download_url":"https://codeload.github.com/Hugo-Dz/rust-sandbox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247949788,"owners_count":21023388,"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":["bevy","game-development","game-engine","gamedev","rust"],"created_at":"2024-11-06T13:38:06.976Z","updated_at":"2025-04-09T00:31:00.305Z","avatar_url":"https://github.com/Hugo-Dz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"screenshots/thumbnail.png\"/\u003e\u003c/p\u003e\n\n# Tiny Sandbox game written in Rust (Bevy)\n\nA little sandbox simulation done without physics, just for fun and to learn a bit of Rust using [Bevy](https://bevyengine.org/).\n\n## Run it locally\n\n- Clone the project\n\n```bash\n  git clone https://github.com/Hugo-Dz/rust-sandbox.git\n  cd rust-sandbox\n```\n\n- Make sure you have Rust [installed](https://www.rust-lang.org/tools/install) and run the following command\n\n```bash\n  cargo run\n```\n\n- That's it! 🎮\n\n## Build for the web\n\n- Install wasm32-unknown-unknown to compile to web assembly\n\n```bash\n  rustup target add wasm32-unknown-unknown\n```\n\n- Install the `wasm-bindgen-cli` tool\n\n```bash\n  cargo install -f wasm-bindgen-cli\n```\n\n- Build the project\n\n```bash\n  cargo build --release --target wasm32-unknown-unknown\n  wasm-bindgen --out-dir ./out/ --target web ./target/wasm32-unknown-unknown/release/sandbox_bevy.wasm\n```\n\nYou should now have a fresh /out folder at the root of your project containing all you need to run your game in a web browser. You can now serve the game with any web server of your choice. Just call the `init()` function from the generated `sandbox_bevy.js` file.\n\n```html\n  \u003cscript type=\"module\"\u003e\n    import init from './sandbox_bevy.js';\n    init();\n  \u003c/script\u003e\n```\n\nThis will automatically load the wasm module and initialize the game in a new canvas element.\n\nIf you want to use your own HTML canvas element, you can specify it in the `Window` Bevy plugin:\n  \n```rust\n  fn main() {\n      App::new()\n          .add_plugins((\n              DefaultPlugins\n                  .set(WindowPlugin {\n                      primary_window: Some(Window {\n                          // Here!\n                          canvas: Some(\"#bevy-canvas\".to_string()),\n                          ..default()\n                      }),\n                  })\n                  .build(),\n          ))\n          .run();\n  }\n```\n\n- Example with SvelteKit\n\n```html\n  \u003cscript lang=\"ts\"\u003e\n\n      // Wasm module\n      import init from \"$lib/pkg/sandbox_bevy\";\n\n      // Svelte\n      import { onMount } from \"svelte\";\n\n      onMount(() =\u003e init() )\n\n  \u003c/script\u003e\n```\n\n## Try it on the web\n\nA [Demo](https://rustsandbox.com) built for the web with SvelteKit is available, feel free to play around it!\n\n## Try it on Hugging Face\n\nA [Demo](https://huggingface.co/spaces/HugoDzz/rust-sandbox) built for the web is on Hugging Face! You can play with it directly in your browser.\n\n## Is Bevy a good fit for game development?\n\nBevy [ECS](https://bevy-cheatbook.github.io/programming/intro-data.html) design was very pleasing to work with, it completely changes the way we can implement game logic compared to the Object-oriented paradigm.\n\nTo be short, imagine your game as a database where each row may or may not have certain components like Enemy, Health: int, Spell: enum... or any tiny piece of data or just empty markers (like Enemy).\n\nRepresenting things this way gives you flexibility. For example, you could create a Health component for your game.\nYou could then have many entities representing different things in your game, such as the player, NPCs, or monsters, all of which can have a Health value (as well as other relevant components).\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"screenshots/data.png\"/\u003e\u003c/p\u003e\n\nThen you can create single pieces of logic (aka Systems) that iterates over all entities with the components matching your query and updates their values. Just like you query a database.\n\n```rust\n  #[derive(Component)]\n  struct Xp(u32);\n\n  #[derive(Component)]\n  struct Health {\n      current: u32,\n      max: u32,\n  }\n\n  fn level_up(\n      // operate on anything that has Xp and Health\n      mut query: Query\u003c(\u0026mut Xp, \u0026mut Health)\u003e,\n  ) {\n      for (mut xp, mut health) in query.iter_mut() {\n          if xp.0 \u003e 1000 {\n              xp.0 -= 1000;\n              health.max += 25;\n              health.current = health.max;\n          }\n      }\n  }\n```\n\nThat said, Bevy is more a framework than a game engine, it's still very early and doesn't provide as many features out of the box as Godot for instance. Especially if you need to do fine level design, the absence of an editor can be annoying.\nAfter playing with it for a while, here are my pros and cons about Bevy:\n\n**Pros:**\n\n✅ The ECS design is very powerful and surprisingly satisfying to work with, especially for simulation or data driven games.  \n✅ Written in the same language as your game.  \n✅ Pretty simple and type-safe! (If you are done to learn a bit of Rust)  \n✅ Customizable and extensible. If you want to build something very specific without reinveting the wheel, it's clearly a good choice.  \n\n\n**Cons:**\n\n❌ No editor, everything sits in your IDE.  \n❌ Lack of common features like particles.  \n❌ Not really beginner friendly, you need to learn a bit of Rust.  \n❌ Not as mature as other game engines, which means less examples and tutorials. That said, the community is very active and helpful on the [Discord](https://discord.gg/bevy)!\n\n## License\n\nMIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugo-dz%2Frust-sandbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugo-dz%2Frust-sandbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugo-dz%2Frust-sandbox/lists"}