⚡C is a powerful and straight-forward language, and using it in null0 is highly recommended.
- 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](https://github.com/WebAssembly/wasi-sdk) installed.
A simple cart might look like this:
And then you can compile to a cart with:
mkdir -p cart
/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: