D

  • Template: cart_d - press "Use this template" and you have a working game.
  • Docker image: ghcr.io/notnullgames/null0-cart-d:latest
  • Your code: cart/main.d, compiled with ldc2
  • Bindings: carts/d/null0.d (baked into the docker image for you)
  • WASI is available, so ordinary file and stdio calls work.
  • See carts made with D
  • API docs for D

building

You do not install ldc2 - 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-d:latest mygame

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

D notes

  • -betterC, so no druntime and no GC.

a cart, in D

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

import null0;

export extern(C) void load() {
    clear(BLUE);
    draw_circle(100, 100, 50, RED);
    draw_text(FONT_DEFAULT, "hello from D", 170, 92, WHITE);
}

// callbacks (optional - implement as needed)
//
//   export extern(C) void update() {}
carts/d/simple/main.d

callbacks

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

export extern(C) void load() {}

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