RocRay

PlatformState

A state record provided by platform on each frame.

{
   frameCount : U64,
   keys : InternalKeyboard.Keys,
   mouse : {
       position : Vector2,
       buttons : Mouse.Buttons,
       wheel : F32,
   },
   timestamp : Time.Time,
   network : {
       peers : {
           connected : List Network.UUID,
           disconnected : List Network.UUID,
       },
       messages : List {
           id : Network.UUID,
           bytes : List U8,
       },
   },
}

NetworkState

NetworkPeers

NetworkMessage

KeyboardKey

Represents a keyboard key, like KeyA or KeyEnter.

Rectangle

Represents a rectangle.

{ x : F32, y : F32, width : F32, height : F32 }

Vector2

Represents a 2D vector.

{ x : F32, y : F32 }

Color

Represents a color using a tag union.

# a generic rgba color
RGBA { r : U8, g : U8, b : U8, a : U8 }

# predefined colors
White
Black
Red
Green
Blue
... etc

Texture

A static image loaded into GPU memory, typically from a file. Once loaded, it can be used multiple times for efficient rendering. Cannot be modified after creation - for dynamic textures that can be drawn to, see RenderTexture instead.

RenderTexture

A special texture that can be used as a render target. Allows drawing operations to be performed to it (like a canvas), making it useful for effects, buffering, or off-screen rendering. The result can then be used like a regular texture.

Sound

A loaded sound resource, used to play audio.

Camera

A camera used to render a 2D perspective of the world.

UUID : Network.UUID

rgba : Color -> InternalColor.RocColor

exit! : {} => {}

Exit the program.

RocRay.exit!

log! : Str, [ LogAll, LogTrace, LogDebug, LogInfo, LogWarning, LogError, LogFatal, LogNone ] => {}

Show a RocRay log trace message.

RocRay.log! "Not yet implemented" LogError

init_window! : { title ? Str, width ? F32, height ? F32 } => {}

get_screen_size! : {} => { height : F32, width : F32 }

Get the window size.

set_target_fps! : I32 => {}

Set the target frames per second. The default value is 60.

display_fps! : { fps : [ Visible, Hidden ], pos : Vector2 } => {}

Display the frames per second, and set the location. The default values are Hidden, 10, 10.

RocRay.displayFPS! { fps: Visible, pos: { x: 10, y: 10 }}

take_screenshot! : Str => {}

Takes a screenshot of current screen (filename extension defines format)

RocRay.takeScreenshot! "screenshot.png"

load_file_to_str! : Str => Result Str [LoadErr Str]

Loads a file from disk

RocRay.loadFileToStr! "resources/example.txt"

send_to_peer! : List U8, UUID => {}

Send a message to a connected peer.

random_i32! : { min : I32, max : I32 } => I32