AssemblyScript

building

You do not install asc - 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-assemblyscript:latest mygame

The template wraps that in npm start, which also serves the result and rebuilds when you save.

AssemblyScript notes

  • Import what you use: import { clear, draw_circle, BLUE } from 'null0.ts' - that exact specifier, not a relative path.
  • Functions taking text take a plain string; the pointer conversion is done for you (the raw *_ptr imports are exported too, if you want them).
  • Built with --runtime stub, so there is no GC - treat allocations as permanent.

a cart, in AssemblyScript

This is carts/as/simple/main.ts in the engine repo - the same file CI builds into the cart below, so it always compiles.

import { clear, draw_circle, draw_text, BLUE, RED, WHITE, FONT_DEFAULT } from 'null0.ts'

export function load(): void {
  clear(BLUE)
  draw_circle(100, 100, 50, RED)
  draw_text(FONT_DEFAULT, 'hello from AssemblyScript', 170, 92, WHITE)
}

// other callbacks you can export:
//
//   export function update(): void {}
carts/as/simple/main.ts

callbacks

A cart implements the callbacks it cares about. In AssemblyScript they look like this:

export function load(): void {}

See anatomy of a cart for the full list and what each one is passed.