Skip to content

notnullgames/null0

Repository files navigation

This combines ideas from pntr_app_starter with wamr to make null0 game-engine (native runtime & libretro core.)

You can see a simple web-demo here or read the docs.

native

After you have the null0 runtime built or downloaded, you can run it like this:

./null0 yourcart.null0

web

You don't need to build anything to use null0 in your own page.

web-component

This is easiest, and will insert your cart as a running game.

Put this anywhere in your page:

<script type="module" src="https://notnullgames.github.io/null0/null0_wc.js"></script>

Now, you can use it like this:

<null0-cart src="https://notnullgames.github.io/null0/cart/input.null0"></null0-cart>

You can use any cart-url in src.

js

You can also use it without a web-componment, if you want:

<script type="module">
import { setupCart } from 'https://notnullgames.github.io/null0/null0.js'
const {host, cart} = await setupCart('mycart.null0')
</script>

2nd param is canvas, if you want to force it to use your existing canvas.

building

In order to build carts, you will need the wasi-sdk installed. You can set WASI_SDK_PREFIX to the location, if it's not /opt/wasi-sdk

Common tasks have been wrapped with npm scripts:

npm run build:site  # build website in docs
npm run start       # run local (reloading) dev-server
npm run clean       # delete all built files

npm run build:carts # build just the demo-carts
npm run build:host  # build just the native host
npm run build:web   # build just the web-host
npm run build:retro # build just the libretro core that can load null0 files

You will need cmake, ninja & emscripten installed.

more on cmake

I like ninja, in the tasks above, because it builds a bit faster, but it's optional, if you use cmake directly.

Essentially, there are 2 cmake defines that effect build:

  • CARTS - Should carts be built?
  • HOST_TYPE - What sort of host are you building (OFF/WEB/RAYLIB/SDL/RETRO)

You can only build 1 HOST_TYPE at a time. CARTS can be paired with any HOST_TYPE, WEB requires emscripten (and should probably be built in a seperate root.)

examples

There are 2 steps: configure & build.

# configure without ninja (plain make) build only carts
cmake -B build -DCARTS=ON -DHOST_TYPE=OFF

# configure for ninja, build only carts
cmake -GNinja -B build -DCARTS=ON -DHOST_TYPE=OFF

# configure for ninja, build only raylib host
cmake -GNinja -B build -DCARTS=OFF -DHOST_TYPE=RAYLIB

# configure for ninja, build only SDL host
cmake -GNinja -B build -DCARTS=OFF -DHOST_TYPE=SDL

# configure for ninja, build only libretro-core
cmake -GNinja -B build -DCARTS=OFF -DHOST_TYPE=RETRO

# configure for ninja, build only web-host (in wbuild/)
emcmake cmake -GNinja -B wbuild

# after configure, build build
cmake --build build

# after configure, build wbuild (for web)
cmake --build wbuild

todo

immediate

  • libretro core (it's working, but colors are off)
  • switch sfx to use pntr_sfx. it's currently broke on web & segfaults on libretro
  • generate headers for other cart-languages (not just C)
  • update website with docs generated from the api defs
  • add web-component & carts from this repo's gh-pages to main-docs
  • implement streaming audio in pntr_app for better samples and generating audio on the fly
  • add complete WASI support to hosts (instead of my IO wrappers, etc)

carts

  • flappybird - needs some improvements. maybe new assets? There are some nice ones. this has nice backgrounds. nice ideas here
  • tetris - this would be a good basic game to implement that wouldn't need any assets
  • pong - another nice basic game. implement simple AI like here
  • tracker - I need to get a basic tracker for samples & sfx made, as a starting point. it would be cool to implement SFX param-changes on the fly, but maybe just pre-load to start (no streaming-audio needed)

longterm

  • test everything, maybe a full battery of wasm-side tests (every single function)
  • add TTS
  • setup a ESP32 host
  • AI? would be cool to embed llama in host, with a flag (disabled by default)
  • Networking? would be cool to at least do basic HTTP, with a flag (disabled by default)
  • standalone DLL for iwasm
  • more games! maybe have a game-contest or something.
  • web-based editor/compiler - I think no installation would be really nice, anmd I could setup editor-environments for specific languages, and even add other editors (like basic tilemap/sprite stuff.)

thanks

See THANKS for acknowledgement and thanks for all the great help & code I received to make this.

license

See LICENSE for licensing information.