{"id":21951755,"url":"https://github.com/rj/bevygap-spaceships","last_synced_at":"2025-09-07T20:33:23.865Z","repository":{"id":258221033,"uuid":"871093528","full_name":"RJ/bevygap-spaceships","owner":"RJ","description":"Lightyear's spaceships demo using bevygap for deployment","archived":false,"fork":false,"pushed_at":"2024-11-14T22:11:59.000Z","size":363,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T01:21:13.149Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/RJ.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":"2024-10-11T08:59:39.000Z","updated_at":"2025-02-26T17:17:47.000Z","dependencies_parsed_at":"2024-11-15T01:01:10.792Z","dependency_job_id":null,"html_url":"https://github.com/RJ/bevygap-spaceships","commit_stats":null,"previous_names":["rj/bevygap-spaceships"],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevygap-spaceships","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevygap-spaceships/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevygap-spaceships/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fbevygap-spaceships/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RJ","download_url":"https://codeload.github.com/RJ/bevygap-spaceships/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366701,"owners_count":21418769,"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-11-29T06:16:38.212Z","updated_at":"2025-04-23T04:02:06.629Z","avatar_url":"https://github.com/RJ.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bevygap Spaceships\n\nA demo multiplayer game using Bevy and Lightyear, ready to deploy to Edgegap's infrastructure to automatically scale server deployment and matchmake..\n\nThis uses my (work-in-progress) [Bevygap](https://github.com/RJ/bevygap) project.\n\nA learning exercise / starter kit / tutorial.\n\nFind me on the bevy discord as @RJ\n\n# Live Demo\n\nIs the [live demo of bevygap-spaceships](https://game.metabrew.com/bevygap-spaceships/) working? Hopefully!\n\n## Running Without Bevygap\n\nTo run server and client during development, without the connect token stuff, edgegap, or matchmaker from bevygap, disable the default bevygap feature:\n\n```\ncargo run --no-default-features -p server\n# and:\ncargo run --no-default-features -p client\n```\n\nNo need to set the `LIGHTYEAR_PRIVATE_KEY`, it'll use all zeros, which is insecure but fine for local development.\n\n## Running with Edgegap in the loop\n\nFollow the setup instructions in the [Bevygap book](https://rj.github.io/bevygap/).\n\nOnce you can deploy containerized game servers to edgegap that successfully startup and connect to your NATS instance, you can run the rest of the components locally, as long as they connect to your NATS.\n\n#### Run the matchmaker\n\nIn the [bevygap](https://github.com/RJ/bevygap) dir (separate repo), run the matchmaker:\n```\n# make sure your NATS_USER etc envs are set!\ncargo run -p bevygap_matchmaker -- --app-name bevygap-spaceships --app-version 1 --lightyear-protocol-id 80085  --lightyear-private-key '1,2, 3, ... 0'\n```\n\nand the matchmaker webservice, which listens on `:3000`:\n\n```\ncargo run -p bevygap_matchmaker_httpd\n```\n\nAnd then from this repo, run the client, setting the matchmaker URL to your local machine:\n\n```\nMATCHMAKER_URL=ws://127.0.0.1:3000/matchmaker/ws cargo run -p client\n```\n\nWhen you click connect in the client, your local matchmaker will end up talking to Edgegap, spawning or selecting a server, and you should find yourself connected to a gameserver running in Edgegap's cloud.\n\n## Remember..\n\nEnsure your envs are set.\n\nRemember the `LIGHTYEAR_PRIVATE_KEY` the server uses must match the key given to the matchmaker for connect tokens to work. You can copy from the rust source and set like this, non alphanumeric chars will be ignored. This would need to be set in Edgegap where the servers are deployed.\n\n```\nLIGHTYEAR_PRIVATE_KEY=\"[1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\"\n```\n\n\n\n## ENV\n\nAttempt to document envs used..\n\n| Environment Variable           | Default                                                                                                      | Description                                                                            |\n| ------------------------------ | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |\n| `LIGHTYEAR_CERTIFICATE_DIGEST` | Empty string                                                                                                 | Only needed if testing wasm clients without bevygap, which sets this for you           |\n| `LIGHTYEAR_PRIVATE_KEY`        | Zeroed key                                                                                                   | Required when using bevygap. Must match value in matchmaker for connect tokens to work |\n| `MATCHMAKER_URL`               | \u003csmall\u003eNative:\u0026nbsp;`ws://localhost:3000/matchmaker/ws`\u003cbr\u003eWasm:\u0026nbsp;`ws(s)://{host}/matchmaker/ws`\u003c/small\u003e | URL of the matchmaker service                                                          |\n\n## Server Notes\n\nTo build a server docker container locally, you can say:\n```\ndocker build -t bevygap-spaceships-server:latest -f server/Dockerfile .\n```\n\nI'm mostly using github actions to bake my containers. See github workflows for details.\n\n## WASM Notes\n\nThe included `client/Dockerfile` builds the wasm and creates a container based on `nginx` which will serve up the `index.html` and wasm assets for you. \n\nIf you don't want to use the docker file:\n\nUse `clang` instead of `cc` for wasm compilation, to avoid weird linker issues on mac/linux.\n\n`apt install clang` on linux or `brew install llvm` on mac.\n\nBuild wasm like this (fixing the path to your clang):\n```\nTARGET_CC=/opt/homebrew/opt/llvm/bin/clang \\\nRUSTFLAGS=--cfg=web_sys_unstable_apis \\\ncargo build --release --target wasm32-unknown-unknown -p client\n\nwasm-bindgen \\\n    --no-typescript \\\n    --target web \\\n    --out-dir ./out \\\n    --out-name \"bevygap-spaceships\" \\\n    ./target/wasm32-unknown-unknown/release/client.wasm\n```\n\nYou can `cd ./out \u0026\u0026 python3 -m http.server` to test locally.\n\n\n\u003e\u003csmall\u003e⚠️ If Mac Docker builds fail with SIGKILL, you may need to increase RAM for Docker's VM\n\u003c/small\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frj%2Fbevygap-spaceships","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frj%2Fbevygap-spaceships","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frj%2Fbevygap-spaceships/lists"}