lukewilliamboswell/roc-ray

Roc graphics and simple games platform

HTML

67

1,261 commits

updated Sep 22, 2026

See the code

README

RocRay

Build native games, visual tools, and interactive apps in Roc, powered by raylib.

RocRay is a focused app platform, not a game engine. Your app keeps its own state and rules; RocRay provides drawing, audio, keyboard and mouse input, windows, recording, files, and networking. It runs on macOS (Intel and Apple Silicon), Linux x64, and Windows x64.

The platform includes the complete RocRay API: value types, pure helpers, and host effects are documented and released together. Import them through your platform dependency, such as rr.App, rr.Math, and rr.Assets.

See what it can do

These nine apps span small games, designed levels, creative tools, responsive interfaces, and scenes with thousands of moving objects. Each tile links to its complete Roc source; the example guide covers the rest and suggests a learning path.

Cave Climb gameplay
Cave Climb

Designed level, jumping, camera, sound
Breakout gameplay
Breakout

Arcade rules, sounds made in code, recording
A scripted responsive interface demonstration
Capture UI

Automated controls and GIF recording
Top Down gameplay
Top Down

Designed map, characters, music, game states
Painting in Pixel Workshop
Pixel Workshop

Drawing pixels and creating sounds in code
An animated postcard composition
Postcard Studio

Generative art and saving larger images
Navigating the responsive settings interface
Responsive Settings

Keyboard, mouse, resizing, display scaling
Source files appearing in Live Plot
Live Plot

Loading and drawing hundreds of thousands of lines
A moving fountain of particles
Particles

Thousands of moving images at once

The capture examples also produce deterministic media directly, including this WebM plot recording.

For performance investigation, RocRay Observatory records host-cycle summaries and opt-in application annotations to a bounded, queryable SQLite .rrstats capture.

Try it

Download the 0.10.0-rc3 example starter and install its declared compiler, nightly-2026-08-23-fb208ba. Unzip it, open a terminal in the extracted directory containing examples/, and run:

roc version
roc examples/hello_world/main.roc

Each starter includes immutable platform URLs and the matching compiler in its application headers. The header records the requirement; it does not install or select the compiler. Run from the extracted directory so asset paths resolve. Use roc build when producing an executable for distribution.

Choose a starting point from the example guide. The platform release contains the tested downloads; the platform's development compiler can be newer.

main contains development source, including examples of unreleased APIs. To run those against the checkout, follow Contributing and use scripts/run-example.py examples/hello_world. Development checks rebind temporary copies to the platform source and its compiler, while published starters keep their own pins.

The programming model

A RocRay app provides three functions:

  • init! runs once. It sets the window options, loads what the app needs, and creates the starting state.
  • update! handles input such as keys and mouse movement, then returns the next state.
  • render! draws that state on the screen.

init! receives App.Io; the update signature is update!(model, input, io). Select a service and call its receivers:

files = io.files()
Task.spawn!(input, || Loaded(files.read_text!("data.json")))
# In a task or init!:
response = io.http().send!(request)?

Development builds deny external services by default. Launch a trusted app with --host-caps-allow-all to grant the previous broad behavior:

scripts/run-example.py examples/http_fetch -- --host-caps-allow-all

Files (including cwd and asset files), networking, processes, SQLite, environment, clipboard, stdout/stderr, and capture output otherwise return PermissionDenied. Drawing, input, generated resources, audio playback, clocks, and timers remain available. This is a host API policy, not an OS sandbox; allow-all does not confine files, network destinations, or child processes.

Reading a file or waiting for a network reply can take time. Start that work as a task so the app can keep updating and drawing; when it finishes, update! receives the result.

Read hello_world/main.roc for the smallest complete app, then choose a project from the example guide. The API reference documents the available features and functions.

Configure a shared startup font when one font serves most of the app. Loading a font file requires --host-caps-allow-all; the built-in font does not:

config = App.default.with_default_font({ path: "assets/body.ttf", size: 32 })
font = io.default_font!()?

Text.Font carries both its opaque host handle and an immutable metric snapshot, so font.measure(...) is pure.

RocRay follows Roc's new compiler closely, and its APIs may still change as the language evolves. Bug reports, documentation improvements, approachable APIs, and focused capabilities are welcome.

roc-lang

Contributors

lukewilliamboswell

1,030 commits

Giesch

153 commits

obust

54 commits

lukewilliamboswell/roc-ray

Roc graphics and simple games platform

HTML

67

1,261 commits

updated Sep 22, 2026

See the code

README

RocRay

Build native games, visual tools, and interactive apps in Roc, powered by raylib.

RocRay is a focused app platform, not a game engine. Your app keeps its own state and rules; RocRay provides drawing, audio, keyboard and mouse input, windows, recording, files, and networking. It runs on macOS (Intel and Apple Silicon), Linux x64, and Windows x64.

The platform includes the complete RocRay API: value types, pure helpers, and host effects are documented and released together. Import them through your platform dependency, such as rr.App, rr.Math, and rr.Assets.

See what it can do

These nine apps span small games, designed levels, creative tools, responsive interfaces, and scenes with thousands of moving objects. Each tile links to its complete Roc source; the example guide covers the rest and suggests a learning path.

Cave Climb gameplay
Cave Climb

Designed level, jumping, camera, sound
Breakout gameplay
Breakout

Arcade rules, sounds made in code, recording
A scripted responsive interface demonstration
Capture UI

Automated controls and GIF recording
Top Down gameplay
Top Down

Designed map, characters, music, game states
Painting in Pixel Workshop
Pixel Workshop

Drawing pixels and creating sounds in code
An animated postcard composition
Postcard Studio

Generative art and saving larger images
Navigating the responsive settings interface
Responsive Settings

Keyboard, mouse, resizing, display scaling
Source files appearing in Live Plot
Live Plot

Loading and drawing hundreds of thousands of lines
A moving fountain of particles
Particles

Thousands of moving images at once

The capture examples also produce deterministic media directly, including this WebM plot recording.

For performance investigation, RocRay Observatory records host-cycle summaries and opt-in application annotations to a bounded, queryable SQLite .rrstats capture.

Try it

Download the 0.10.0-rc3 example starter and install its declared compiler, nightly-2026-08-23-fb208ba. Unzip it, open a terminal in the extracted directory containing examples/, and run:

roc version
roc examples/hello_world/main.roc

Each starter includes immutable platform URLs and the matching compiler in its application headers. The header records the requirement; it does not install or select the compiler. Run from the extracted directory so asset paths resolve. Use roc build when producing an executable for distribution.

Choose a starting point from the example guide. The platform release contains the tested downloads; the platform's development compiler can be newer.

main contains development source, including examples of unreleased APIs. To run those against the checkout, follow Contributing and use scripts/run-example.py examples/hello_world. Development checks rebind temporary copies to the platform source and its compiler, while published starters keep their own pins.

The programming model

A RocRay app provides three functions:

  • init! runs once. It sets the window options, loads what the app needs, and creates the starting state.
  • update! handles input such as keys and mouse movement, then returns the next state.
  • render! draws that state on the screen.

init! receives App.Io; the update signature is update!(model, input, io). Select a service and call its receivers:

files = io.files()
Task.spawn!(input, || Loaded(files.read_text!("data.json")))
# In a task or init!:
response = io.http().send!(request)?

Development builds deny external services by default. Launch a trusted app with --host-caps-allow-all to grant the previous broad behavior:

scripts/run-example.py examples/http_fetch -- --host-caps-allow-all

Files (including cwd and asset files), networking, processes, SQLite, environment, clipboard, stdout/stderr, and capture output otherwise return PermissionDenied. Drawing, input, generated resources, audio playback, clocks, and timers remain available. This is a host API policy, not an OS sandbox; allow-all does not confine files, network destinations, or child processes.

Reading a file or waiting for a network reply can take time. Start that work as a task so the app can keep updating and drawing; when it finishes, update! receives the result.

Read hello_world/main.roc for the smallest complete app, then choose a project from the example guide. The API reference documents the available features and functions.

Configure a shared startup font when one font serves most of the app. Loading a font file requires --host-caps-allow-all; the built-in font does not:

config = App.default.with_default_font({ path: "assets/body.ttf", size: 32 })
font = io.default_font!()?

Text.Font carries both its opaque host handle and an immutable metric snapshot, so font.measure(...) is pure.

RocRay follows Roc's new compiler closely, and its APIs may still change as the language evolves. Bug reports, documentation improvements, approachable APIs, and focused capabilities are welcome.

roc-lang

Contributors

lukewilliamboswell

1,030 commits

Giesch

153 commits

obust

54 commits

Languages

HTML

94.4%

Zig

3.0%