In the "Steps" section, replace my-game
with the path to wherever your actual project dir is in the following commands.
âšī¸ You should run all these commands from the project root directory.
From the my-game
dir run:
cd my-game && cargo build -r --target wasm32-unknown-unknown
cp my-game/target/wasm32-unknown-unknown/release/my_game.wasm www/my_game.wasm
Note that the wasm binary will replace dashes in the package name with underscores.
Be extra careful not to delete the sprites in your project dir!
rm -rf www/sprites && cp -r my-game/sprites www/sprites
The most important parts are the wasm source, resolution, and the sprites in www/main.js
.
If you are using solana features, be sure to update the rpc urls in www/solana.js
.
5. Update www/manifest.json
, www/favicon.ico
, www/logo_192x192.png
, the meta tags in www/index.html
, etc
This is how you can customize your game's appearance as a PWA.
You just copy the content of the www
to whatever hosting service you are using :)
If you want to see a preview beforehand, just start a local server and host that dir.
I see an error on the console: JsValue(CompileError: WebAssembly.instantiate(): expected magic word ....)
Double check the WASM_SRC
in www/main.js
;
Make sure the files are in www/sprites
and make sure you add their paths in www/main.js
If you did a non-release build, it may be in target/wasm32-unknown-unknown/debug
. Turbo defaults to release builds. But if you compile the game manually just be careful. Either build will work on the web. The release build will be smaller / download faster.
www/sw.js
is copy-pasta boilerplate, yeah that thing needs to get updated sorry. I should get around to it soon. But feel free to make a PR in the meantime if you want!
Feel free to mess with the css in www/style.css