peterhellberg/w4
A small Zig ⚡ module, primarily meant for my own experiments with WASM-4
A small Zig ⚡ module, primarily meant for my own experiments with WASM-4 🎮
Based on the wasm4.zig template
IMPORTANT You might want to install the w4-init tool and use that instead of manually creating the files for your cart.
You can have zig build
retrieve the w4
module if you specify it as a dependency.
build.zig.zon
that looks something like this:.{
.name = .w4_game,
.fingerprint = 0x9364c2ea98294635,
.version = "0.0.0",
.paths = .{""},
.dependencies = .{
.w4 = .{
.url = "https://github.com/peterhellberg/w4/archive/refs/tags/v0.1.0.tar.gz",
},
},
}
NOTE If you leave out the hash then
zig build
will tell you that it is missing the hash, and what it is. Another way to get the hash is to usezig fetch
, this is probably how you should do it :)
build.zig
like this:// Add the w4 module to the executable
exe.addModule("w4", b.dependency("w4", .{}).module("w4"));
src/main.zig
you should now be able to:const w4 = @import("w4");
export fn start() void {}
export fn update() void {
const hello = "Hello from Zig!";
w4.color(2);
w4.text(hello, 15, 11);
w4.color(3);
w4.text(hello, 16, 10);
}