From ffd69260e16b5318c0e20f35f376f6df3344912a Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Tue, 16 Jan 2024 20:48:17 -0800 Subject: [PATCH 1/2] Update README.md Just some extra notes I thought would be good to add to the readme. --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bbda3f8..88d38dc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Make sure you have [roc](https://www.roc-lang.org/install) newer than 2023-1-8, For the *web runtime* use `zig build run` -For the *native runtime* use `zig build run-native` +For the *native runtime* use `zig build run-native` (Note: native can often be much slower than web especially for non-optimized builds) The `build.zig` script reports any warnings or errors for the app using `roc check`, it then builds an object file using `roc build --target=wasm32 --no-link` and links this with the host to produce the final `.wasm` game cartridge. @@ -49,10 +49,21 @@ Thank you Brendan Hansknecht and Luke DeVault (art) for this demo. To generate locally use `roc docs platform/main.roc`, and then use a file server `simple-http-server generated-docs/`. +### Hot Reloading + +Well it isn't perfect, hot reloading can be quite nice when developing a game. For this, I suggest using the [entr]() command line tool. + +In one terminal run the build command: `find . -name "*.roc" -o -name "*.zig" | entr -cc zig build -Dapp=`. + +In another terminal run wasm4: `w4 run zig-out/lib/cart.wasm --hot`. + +If the hot reloading breaks (which it often does when changing the data layout or state), simply press `R` to reload the cart. + ### Distribution To release a game, first build it with optimizations by adding `-Doptimize=ReleaseSmall`. Then bundle it [like any other wasm4 game](https://wasm4.org/docs/guides/distribution/) using the generated cartidge located in `zig-out/lib/cart.wasm`. +If your cartidge is too large, you can try lowering the dynamic memory space with `-Dmem-size=`. The default is `40960` bytes. For example, a web release can be built with: ```shell From dce0345d5e00a0a0de9236e134ff506612c746b6 Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Tue, 16 Jan 2024 20:49:21 -0800 Subject: [PATCH 2/2] Add url to entr --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 88d38dc..bb63515 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ To generate locally use `roc docs platform/main.roc`, and then use a file server ### Hot Reloading -Well it isn't perfect, hot reloading can be quite nice when developing a game. For this, I suggest using the [entr]() command line tool. +Well it isn't perfect, hot reloading can be quite nice when developing a game. For this, I suggest using the [entr](https://github.com/eradman/entr) command line tool. In one terminal run the build command: `find . -name "*.roc" -o -name "*.zig" | entr -cc zig build -Dapp=`.