C

  • See cart structure for more info about how callbacks work.
  • See API for more info about the null0 API.
  • See examples
  • You can use WASI too, so all regular C stdlib-file stuff should work.
  • Check out the C template project
  • You will need wasi-sdk installed.
  • The definitive header is here, so use that to ensure yours is up-to-date

A simple cart might look like this:

And then you can compile to a cart with:

mkdir -p cart
curl https://raw.githubusercontent.com/notnullgames/null0/refs/heads/main/carts/c/null0.h > null0.h
/opt/wasi-sdk/bin/clang main.c -o cart/main.wasm
cd cart
zip -rq ../mygame.null0 .

See build.sh for an example of how I build for this example-site.

For clang command, you can use -I WHEREVER_NULL0_H_IS if null0.h is in another directory.

For zip command, you can skip packaging some files (like .DS_Store and *.c) with -x ".DS_Store" "__*" "*.c" "*.h" (after all the other options.)

Anything in the zip-file is available in WASI filesystem, or any of the null0 api, so if you have cart/logo.png, and you want to draw it in the middle of the screen, do this:

That looks like this: