Exit the application with the given exit code. The exit happens after the current frame completes to allow proper cleanup.
Host
:= {
frame_count : U64,
timestamp_nanos : U64,
frame_time : F32,
keys : List(U8),
keys_pressed : List(U8),
keys_released : List(U8),
mouse : {
buttons : List(U8),
buttons_pressed : List(U8),
buttons_released : List(U8),
left : Bool,
middle : Bool,
right : Bool,
wheel : F32,
x : F32,
y : F32,
},
}
Host module - provides platform state and system effects
get_screen_size! : () => ScreenSize
Get the current screen/window dimensions.
read_env_raw! : Host, Str => Try(Str, [NotFound])
Read an environment variable by key. Returns Ok with the value if found, or Err NotFound if not set.
Read an environment variable by key. Returns Ok with the value if found, or Err NotFound if not set.
read_file_raw! : Str => ReadFileRawResult
Raw hosted file read. Prefer read_file!.
read_file! : Str => Try(Str, [NotFound, ReadFailed])
Read a UTF-8 text file from disk.
random_i32! : I32, I32 => I32
Get a random integer in the range [min, max] (both endpoints included).
The generator is seeded once at startup, so sequences differ between runs.
Derive other ranges/floats from this, e.g. a random direction with
if Host.random_i32!(0, 1) == 0 -1 else 1.
set_screen_size_raw! : { width : F32, height : F32 } => Try({ }, [NotSupported])
Set the window/screen size. Returns Err NotSupported on platforms that don't support window resizing (e.g., web).
set_screen_size! : { width : F32, height : F32 } => Try({ }, [NotSupported])
Set the window/screen size. Returns Err NotSupported on platforms that don't support window resizing (e.g., web).
set_target_fps! : I32 => { }
Set the target frames per second for the render loop. Note: On web/WASM, this has no effect as the browser controls frame timing.
ScreenSize : { width : I32, height : I32 }
ReadFileRawResult : {
ok : Bool,
err : U8,
contents : Str,
}