Reight - A retro game engine for Ruby

May 15, 2026 ยท View on GitHub

Ask DeepWiki License Build Status Gem Version

โš ๏ธ Notice

This repository is a read-only mirror of our monorepo. We do not accept pull requests or direct contributions here.

๐Ÿ”„ Where to Contribute?

All development happens in our xord/all monorepo, which contains all our main libraries. If you'd like to contribute, please submit your changes there.

For more details, check out our Contribution Guidelines.

Thanks for your support! ๐Ÿ™Œ

๐Ÿš€ About

Reight is a small, fantasy-console-style game engine for Ruby. It runs a fixed 400 ร— 224 screen, a 32-color palette, and an 8 ร— 8 pixel chip / sprite size, and ships with built-in sprite / map / sound editors so you can author all assets without leaving the tool.

Under the hood it builds on the rest of the xord/* family โ€” Reight's runtime is essentially RubySketch (and Processing under it), restricted to a retro-friendly framebuffer and extended with project storage, a chunked tile map, a chip / tileset system, and an editing UI.

A project is just a directory of plain files:

mygame/
โ”œโ”€โ”€ project.json   # screen size, font, file names, ...
โ”œโ”€โ”€ game.rb        # your game code (uses Reight's top-level API)
โ”œโ”€โ”€ chips.png      # tileset image
โ”œโ”€โ”€ chips.json     # tile metadata (shapes, sensors, ...)
โ”œโ”€โ”€ maps.json      # tile-map data (chunked)
โ””โ”€โ”€ sounds.json    # sound data

๐Ÿ“‹ Requirements

  • Ruby 3.0.0 or later
  • All the runtime requirements of Reflex (Rays, Rucy, Xot, plus the platform GUI backend โ€” AppKit / UIKit / Win32 / SDL2 โ€” and OpenGL)
  • The dependent gems are installed automatically: xot, rucy, beeps, rays, reflexion, processing, rubysketch

There is no native C/C++ extension in this gem; the heavy lifting is done by the underlying gems' extensions.

๐Ÿ“ฆ Installation

Add this line to your Gemfile:

gem 'reight'

Then install:

$ bundle install

Or install it directly:

$ gem install reight

The gem also installs a r8 command-line tool used to run and edit projects.

โ–ถ๏ธ The r8 command

$ r8 [DIR]              # run the project in DIR (default: current directory)
$ r8 --edit [DIR]       # open the project in the built-in editor
$ r8 --help             # show all options

DIR is the project directory described above. If it does not contain a project.json, defaults are used.

Built-in editor screens

When launched with --edit, the engine adds these tabs alongside the game runner:

EditorPurposeTools (lib/reight/app/<name>/)
SpritePixel-art editor for the chip / tileset image (chips.png)brush, fill, color picker, line, rect / shape, select
MapChunk-based tile-map editorbrush, line, rect
SoundWaveform-based sound editorbrush, eraser

The currently active tab is switched from the top navigator bar.

๐Ÿ“š What's Provided

require 'reight' makes a refinement-based API available, much like Processing and RubySketch. The full Processing + RubySketch vocabulary is exposed at the top level (camelCase and snake_case aliases), and Reight adds the pieces below.

Reight-specific API

APIPurpose
projectThe active Reight::Project โ€” accessors for chips, maps, sounds, project paths, font, etc.
Reight::SpriteA subclass of RubySketch::Sprite carrying an optional chip and a per-instance props hash; default sprite class returned by createSprite inside Reight
Reight::ChipA single tile from the tileset โ€” id, position / size in chips.png, optional collision shape and sensor flag
Reight::MapChunk-based tile map (chip_size: 8, chunk_size: 128 by default); Enumerable, with to_sprites and live activate(x, y, w, h, world) for visible regions
Reight::SoundPersistent sound asset, edited by the Sound editor
Reight::ProjectLoads and saves the JSON / PNG files described above

Constants on Reight::App

ConstantValueMeaning
SCREEN_WIDTH400Fixed framebuffer width
SCREEN_HEIGHT224Fixed framebuffer height
PALETTE_COLORS32 entriesDefault 32-color hex palette (transparent first, then a PICO-8-flavored set)

The window opens at 3ร— the framebuffer size by default; the framebuffer is upscaled with no smoothing for a crisp pixel-art look.

๐Ÿ’ก Usage

Minimal game.rb

draw do
  background 0
  fill 1
  text 'hello, reight!', 10, 100
end

Run it from the project directory:

$ r8 .

Move a sprite with the cursor keys

player = createSprite 200, 112, 8, 8

player.update do
  player.x += 1 if key_is_down(RIGHT)
  player.x -= 1 if key_is_down(LEFT)
end

draw do
  background 0
  sprite player
end

Draw the first map of the project

draw do
  background 0
  $sprites ||= project.maps.first.to_sprites
  sprite *$sprites
end

(Open r8 --edit . first to draw the map, then run r8 . to play it.)

Use chip properties

Chips have a props hash you can read from your game code:

$sprites ||= project.maps.first.to_sprites.each do |sp|
  sp.dynamic = true if sp.chip.props[:dynamic]
end

๐Ÿ› ๏ธ Development

$ rake test    # run the test suite
$ rake doc     # generate YARD docs
$ rake         # default tasks

In the xord/all monorepo you can scope by module, e.g. rake reight test.

There is also a WASM build pipeline under wasm/ that packages the engine and your project for the browser via Emscripten + ruby.wasm.

๐Ÿ“œ License

Reight is licensed under the MIT License. See the LICENSE file for details.