👑Nim reads a bit like Python and compiles through C, so it is fast and small. A good middle ground if C feels too bare.
- Template: cart_nim - press "Use this template" and you have a working game.
- Docker image:
ghcr.io/notnullgames/null0-cart-nim:latest - Your code:
cart/main.nim, compiled with nim + wasi-sdk clang - Bindings:
carts/nim/null0.nim(baked into the docker image for you) - WASI is available, so ordinary file and stdio calls work.
- See carts made with Nim
- API docs for Nim
building
You do not install nim + wasi-sdk clang - the docker image has it, and the current null0 bindings, baked in. There is nothing in your project to keep in sync with the engine.
docker run --rm --user $(id -u):$(id -g) \
-v ./cart:/src -v ./webroot:/out \
ghcr.io/notnullgames/null0-cart-nim:latest mygameThe template wraps that in npm start, which also serves the result and rebuilds when you save.
Nim notes
import null0.
a cart, in Nim
This is carts/nim/simple/main.nim in the engine repo - the same file CI builds into the cart below, so it always compiles.
import null0
proc load*() {.wasm.} =
clear(BLUE)
draw_circle(100, 100, 50, RED)
draw_text(FONT_DEFAULT, "hello from Nim", 170, 92, WHITE)
# callbacks (optional - implement as needed)
#
# proc update*() {.wasm.} =
# discard
carts/nim/simple/main.nimcallbacks
A cart implements the callbacks it cares about. In Nim they look like this:
proc load*() {.wasm.} =See anatomy of a cart for the full list and what each one is passed.