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.
.{
.name = "w4-game",
.version = "0.0.0",
.paths = .{""},
.dependencies = .{
.w4 = .{
.url = "https://github.com/peterhellberg/w4/archive/refs/tags/v0.0.2.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 use zig fetch
, this is probably how you should do it :)
// Add the w4 module to the executable
exe.addModule("w4", b.dependency("w4", .{}).module("w4"));
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);
}