Skip to content

About

Roc graphics and simple games platform

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

RocRay

Make 2D games, visual tools, and interactive apps in Roc, powered by raylib.

RocRay is for smaller graphical programs, such as games, visualizations, and interactive tools. It is not meant to compete with large, purpose-built game engines: it has no editor, scene graph, physics engine, or asset pipeline. Your app keeps its own state and makes every decision itself; RocRay provides drawing, sound, keyboard, mouse and gamepad input, the window, recording, files, and networking. It runs on macOS (Intel and Apple silicon), Linux x86-64, and Windows x86-64.

RocRay draws in 2D today. 3D models, cameras, and lighting are planned but not yet available. RocRay is not a GUI toolkit: for desktop applications built from widgets such as buttons, text fields, and layouts, see roc-gui.

Start with Hello World, Pong, and Snake. These larger examples show what else it can do:

Breakout gameplay
Breakout

Arcade gameplay, sounds made in code, recording
Painting in Pixel Workshop
Pixel Workshop

Drawing pixels and creating sounds in code
Navigating the responsive settings interface
Responsive Settings

Keyboard, mouse, resizing, display scaling
An animated postcard composition
Postcard Studio

Generative art and saving larger images
A moving fountain of particles
Particles

Thousands of moving images at once
A scripted responsive interface demonstration
Capture UI Demo

Automated controls and GIF recording
Source files appearing in Live Plot
Live Plot

Loading and drawing hundreds of thousands of lines
Spark Run gameplay
Spark Run

Designed map, characters, music, game states
Cave Climb gameplay
Cave Climb

Designed level, jumping, camera

Try it

  1. Open the latest release and install the Roc compiler its notes name, as Getting started describes.
  2. Download that release's examples-<version>.zip and unzip it.
  3. Open a terminal in the extracted directory, the one containing examples/, and run:
roc version
roc examples/hello_world/main.roc

A whole app

A red circle that follows the mouse. Replace BUNDLE-URL and COMPILER with the default bundle URL and the compiler the release notes name.

app [Model, program] { rr: platform "BUNDLE-URL", roc: "COMPILER" }

import rr.App
import rr.Color
import rr.Draw

Model : { pointer : { x : F32, y : F32 } }

Msg : []

program = { init!, update!, render! }

init! : App.Init(Model, [])
init! = App.init(App.default.with_title("Hello"), |_io| Ok({ pointer: { x: 400, y: 300 } }))

update! : Model, App.Input(Msg), App.Io => Try(Model, [Exit(I64)])
update! = |_model, input, _io| Ok({ pointer: input.devices.mouse.position() })

render! : Model, Draw.Frame => Try({}, [Exit(I64)])
render! = |model, frame| {
    frame.clear!(Color.black)
    frame.circle!({ center: model.pointer, radius: 40, style: Draw.filled(Color.red) })
    Ok({})
}

init! creates the starting state, update! uses each host cycle's input to compute the next state, and render! draws it. Anything that waits, such as reading a file or fetching a URL, runs as a task, and its result arrives in a later update!. Anything the app accesses beyond its own window, such as the network, a directory, or another program, is declared in its startup settings.

Documentation

The RocRay manual is published as a website and a PDF. Its chapters are the AsciiDoc files in docs/, which you can also read here:

RocRay tracks recent nightly builds of the Roc compiler. Because Roc is still changing, RocRay's API may also change. Bug reports, documentation improvements, and focused new capabilities are welcome.

About

Roc graphics and simple games platform

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages