ryupold / examples-raylib.zig

Example usage of raylib.zig bindings
MIT License
43 stars 4 forks source link

raylib.zig examples

This is a collection of examples using the Zig raylib bindings of raylib.zig

supported platforms

examples

During build you will be asked which example should be executed. The example code can be found in ./src/examples.

You can test the WebGL examples here.

BUILD

dependencies

git clone --recurse-submodules https://github.com/ryupold/examples-raylib.zig

run locally

zig build run # runs first example (hello_world)
zig build run -Dexample=5 # runs example no. 5

build for host os and architecture

zig build -Doptimize=ReleaseSmall
zig build -Doptimize=ReleaseSmall -Dexample=6 # build example no. 6

The output files will be in ./zig-out/bin

html5 / emscripten

cd <emscripten directory>

./emsdk_env.ps1 # windows
./emsdk_env.sh # linux / macos

zig build -Doptimize=ReleaseSmall -Dtarget=wasm32-wasi --sysroot "<emscripten directory>/upstream/emscripten"

The output files will be in ./zig-out/web/

The game data needs to be served with a webserver. Just opening the game.html in a browser won't work

You can utilize python as local http server:

python -m http.server