reight 0.1.17 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/release-gem.yml +5 -16
- data/.github/workflows/utils.rb +88 -17
- data/.github/workflows/wasm.yml +37 -0
- data/ChangeLog.md +14 -0
- data/README.md +145 -28
- data/VERSION +1 -1
- data/lib/reight/extension.rb +4 -2
- data/reight.gemspec +8 -8
- data/wasm/.bundle/config +2 -0
- data/wasm/.gitignore +4 -0
- data/wasm/Gemfile +13 -0
- data/wasm/Gemfile.lock +95 -0
- data/wasm/Rakefile +106 -0
- metadata +22 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d3674b778fe6d2453add5a4a9ba1cdea93f9d8a3a27d584d929894b6fc63b561
|
|
4
|
+
data.tar.gz: c322aea76c3ff5b319990d4ec14fd3b864d6573082ebd5c42334608fc70c4fe8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f5b6c8abff843e9b3b7bd0478ee9bcf8da602cae8195a12b770bd94820a05df0d87569df2524f3d740301c0dbe132be25a04c4f4b762c959667ac04966708ef
|
|
7
|
+
data.tar.gz: d9487e23499975c8e890cc8b6c6055fadb01365f86f0c65f5680dad7d1188a3ade44436aa6899c7826943893fdf69c0bdee2416b89883273953978cadd3170bb
|
|
@@ -4,6 +4,9 @@ on:
|
|
|
4
4
|
push:
|
|
5
5
|
tags: ['v[0-9]*']
|
|
6
6
|
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
7
10
|
jobs:
|
|
8
11
|
release:
|
|
9
12
|
runs-on: macos-latest
|
|
@@ -33,23 +36,9 @@ jobs:
|
|
|
33
36
|
echo path=$(ruby -e 'print Dir.glob("*.gem").first') >> $GITHUB_OUTPUT
|
|
34
37
|
|
|
35
38
|
- name: create github release
|
|
36
|
-
id: release
|
|
37
|
-
uses: actions/create-release@v1
|
|
38
39
|
env:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
tag_name: ${{ github.ref }}
|
|
42
|
-
release_name: ${{ github.ref }}
|
|
43
|
-
|
|
44
|
-
- name: upload to github release
|
|
45
|
-
uses: actions/upload-release-asset@v1
|
|
46
|
-
env:
|
|
47
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
48
|
-
with:
|
|
49
|
-
upload_url: ${{ steps.release.outputs.upload_url }}
|
|
50
|
-
asset_path: ./${{ steps.gem.outputs.path }}
|
|
51
|
-
asset_name: ${{ steps.gem.outputs.path }}
|
|
52
|
-
asset_content_type: application/zip
|
|
40
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
41
|
+
run: ruby -I.github/workflows -rutils -e 'release(*ARGV)' ./${{ steps.gem.outputs.path }}
|
|
53
42
|
|
|
54
43
|
- name: upload to rubygems
|
|
55
44
|
env:
|
data/.github/workflows/utils.rb
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
require 'shellwords'
|
|
2
|
+
|
|
3
|
+
ALL_REPO = 'xord/all'
|
|
4
|
+
ALL_DIR = '../all'
|
|
5
|
+
ALL_FETCH_DEPTH = 100
|
|
6
|
+
|
|
1
7
|
RENAMES = {reflex: 'reflexion'}
|
|
2
8
|
|
|
3
9
|
def sh(cmd)
|
|
@@ -5,7 +11,7 @@ def sh(cmd)
|
|
|
5
11
|
system cmd
|
|
6
12
|
end
|
|
7
13
|
|
|
8
|
-
def setup_dependencies(
|
|
14
|
+
def setup_dependencies(only: nil)
|
|
9
15
|
gemspec_path = `git ls-files`.lines(chomp: true).find {|l| l =~ /\.gemspec$/}
|
|
10
16
|
return unless gemspec_path
|
|
11
17
|
|
|
@@ -13,44 +19,109 @@ def setup_dependencies(build: true, only: nil)
|
|
|
13
19
|
name = File.basename gemspec_path, '.gemspec'
|
|
14
20
|
|
|
15
21
|
exts = File.readlines('Rakefile')
|
|
16
|
-
.map {|l| l[%r|^\s*require\W+(\w+)/extension\W+$|, 1]}
|
|
22
|
+
.map {|l| l[%r|^\s*require\W+([\w\-\_]+)/extension\W+$|, 1]}
|
|
17
23
|
.compact
|
|
18
24
|
.reject {|ext| ext == name}
|
|
19
25
|
exts = exts & [only].flatten.map(&:to_s) if only
|
|
26
|
+
return if exts.empty?
|
|
27
|
+
|
|
28
|
+
unless setup_dependencies_via_monorepo(exts)
|
|
29
|
+
setup_dependencies_via_each_repo_by_version(gemspec, exts)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
exts.each {|ext| sh %( cd ../#{ext} && rake ext )}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def setup_dependencies_via_monorepo(exts)
|
|
36
|
+
return false unless checkout_monorepo
|
|
37
|
+
exts.each {|ext| sh %( ln -snf all/#{ext} ../#{ext} )}
|
|
38
|
+
true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def checkout_monorepo()
|
|
42
|
+
uuid = `git log -1 --format=%B`[/^\[\[([0-9a-fA-F-]+)\]\]$/, 1]
|
|
43
|
+
return false unless uuid
|
|
44
|
+
|
|
45
|
+
commit = setup_monorepo uuid
|
|
46
|
+
return false unless commit
|
|
47
|
+
|
|
48
|
+
Dir.chdir(ALL_DIR) {sh %( git checkout -q #{commit} )}
|
|
49
|
+
true
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def setup_monorepo(uuid)
|
|
53
|
+
unless File.directory? ALL_DIR
|
|
54
|
+
url = "https://github.com/#{ALL_REPO}.git"
|
|
55
|
+
sh %( git clone --no-tags --depth #{ALL_FETCH_DEPTH} #{url} #{ALL_DIR} )
|
|
56
|
+
end
|
|
57
|
+
loop do
|
|
58
|
+
commit = find_monorepo_commit uuid
|
|
59
|
+
return commit if commit
|
|
60
|
+
|
|
61
|
+
deepened = Dir.chdir ALL_DIR do
|
|
62
|
+
before = `git rev-list --count HEAD`.to_i
|
|
63
|
+
sh %( git fetch --deepen #{ALL_FETCH_DEPTH} )
|
|
64
|
+
`git rev-list --count HEAD`.to_i > before
|
|
65
|
+
end
|
|
66
|
+
return nil unless deepened
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def find_monorepo_commit(uuid)
|
|
71
|
+
Dir.chdir ALL_DIR do
|
|
72
|
+
out = `git log origin/HEAD -F --grep="[[#{uuid}]]" --format=%H -1`.strip
|
|
73
|
+
out.empty? ? nil : out
|
|
74
|
+
end
|
|
75
|
+
end
|
|
20
76
|
|
|
77
|
+
def setup_dependencies_via_each_repo_by_version(gemspec, exts)
|
|
21
78
|
exts.each do |ext|
|
|
22
79
|
gem = RENAMES[ext.to_sym].then {|s| s || ext}
|
|
23
|
-
ver = gemspec[/add_dependency.*['"]#{gem}['"].*['"]\s
|
|
80
|
+
ver = gemspec[/add_dependency.*['"]#{gem}['"].*['"]\s*~>\s*([\d\.]+)\s*['"]/, 1]
|
|
24
81
|
opts = '-c advice.detachedHead=false --depth 1'
|
|
25
82
|
clone = "git clone #{opts} https://github.com/xord/#{ext}.git ../#{ext}"
|
|
26
83
|
|
|
27
84
|
# 'rake subtree:push' pushes all subrepos, so cloning by new tag
|
|
28
85
|
# often fails before tagging each new tag
|
|
29
86
|
sh %( #{clone} --branch v#{ver} || #{clone} )
|
|
30
|
-
sh %( cd ../#{ext} && rake ext )
|
|
31
87
|
end
|
|
32
88
|
end
|
|
33
89
|
|
|
34
90
|
def tag_versions()
|
|
35
|
-
|
|
36
|
-
|
|
91
|
+
changes = changelogs
|
|
92
|
+
tags = `git tag`.lines chomp: true
|
|
93
|
+
vers = `git log --oneline ./VERSION`
|
|
37
94
|
.lines(chomp: true)
|
|
38
95
|
.map {|line| line.split.first[/^\w+$/]}
|
|
39
|
-
.map {|
|
|
40
|
-
.select {|ver,
|
|
96
|
+
.map {|sha| [`git cat-file -p #{sha}:./VERSION 2>/dev/null`[/[\d\.]+/], sha]}
|
|
97
|
+
.select {|ver, sha| ver && sha}
|
|
41
98
|
.reverse
|
|
42
99
|
.to_h
|
|
43
100
|
|
|
44
|
-
|
|
45
|
-
.split(/^\s*##\s*\[\s*v([\d\.]+)\s*\].*$/)
|
|
46
|
-
.slice(1..-1)
|
|
47
|
-
.each_slice(2)
|
|
48
|
-
.to_h
|
|
49
|
-
.transform_values(&:strip!)
|
|
50
|
-
|
|
51
|
-
vers.to_a.reverse.each do |ver, hash|
|
|
101
|
+
vers.to_a.reverse.each do |ver, sha|
|
|
52
102
|
tag = "v#{ver}"
|
|
53
103
|
break if tags.include?(tag)
|
|
54
|
-
sh %( git tag -a -m \"#{changes[
|
|
104
|
+
sh %( git tag -a -m \"#{changes[tag]&.gsub '"', '\\"'}\" #{tag} #{sha} )
|
|
55
105
|
end
|
|
56
106
|
end
|
|
107
|
+
|
|
108
|
+
def release(*paths)
|
|
109
|
+
tag = ENV['GITHUB_REF']&.sub(%r|^refs/tags/|, '') || raise('GITHUB_REF tag not set')
|
|
110
|
+
notes = (changelogs[tag] || '').shellescape
|
|
111
|
+
paths = paths.flatten.join ' '
|
|
112
|
+
|
|
113
|
+
sh(%( gh release create #{tag} #{paths} --notes #{notes} )) ||
|
|
114
|
+
sh(%( gh release upload #{tag} #{paths} --clobber )) ||
|
|
115
|
+
raise('failed to upload to releases')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def changelogs()
|
|
119
|
+
File.read('ChangeLog.md')
|
|
120
|
+
.split(/^\s*##\s*\[\s*(v[\d\.]+)\s*\].*$/)
|
|
121
|
+
.slice(1..)
|
|
122
|
+
.each_slice(2)
|
|
123
|
+
.to_h
|
|
124
|
+
.transform_values(&:strip!)
|
|
125
|
+
rescue Errno::ENOENT
|
|
126
|
+
raise 'failed to get changelogs'
|
|
127
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Release WASM
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v[0-9]*']
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
wasm:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: ruby 3.2
|
|
16
|
+
uses: ruby/setup-ruby@v1
|
|
17
|
+
with:
|
|
18
|
+
ruby-version: 3.2
|
|
19
|
+
|
|
20
|
+
- name: checkout
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: checkout monorepo
|
|
24
|
+
run: ruby -I.github/workflows -rutils -e 'abort unless checkout_monorepo'
|
|
25
|
+
|
|
26
|
+
- name: install emscripten
|
|
27
|
+
uses: mymindstorm/setup-emsdk@v14
|
|
28
|
+
with:
|
|
29
|
+
version: 5.0.7
|
|
30
|
+
|
|
31
|
+
- name: build
|
|
32
|
+
run: cd ../all/reight/wasm && rake build
|
|
33
|
+
|
|
34
|
+
- name: upload to release
|
|
35
|
+
env:
|
|
36
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
37
|
+
run: ruby -I.github/workflows -rutils -e 'release(*Dir.glob("../all/reight/wasm/output/*"))'
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# reight ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.2.0] - 2026-05-17
|
|
5
|
+
|
|
6
|
+
- [BREAKING] Wheel Y delta now follows top-left origin convention (from reflex)
|
|
7
|
+
|
|
8
|
+
- Rewrite README.md
|
|
9
|
+
- CI: Migrate release-gem.yml from actions/create-release to gh release create
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## [v0.1.18] - 2026-05-10
|
|
13
|
+
|
|
14
|
+
- Support WebAssembly
|
|
15
|
+
- Add reight WASM release workflow
|
|
16
|
+
|
|
17
|
+
|
|
4
18
|
## [v0.1.17] - 2026-04-17
|
|
5
19
|
|
|
6
20
|
- Update dependencies
|
data/README.md
CHANGED
|
@@ -1,68 +1,185 @@
|
|
|
1
|
-
# Reight - A
|
|
1
|
+
# Reight - A retro game engine for Ruby
|
|
2
2
|
|
|
3
3
|
[](https://deepwiki.com/xord/reight)
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|

|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## ⚠️ Notice
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This repository is a read-only mirror of our monorepo.
|
|
11
|
+
We do not accept pull requests or direct contributions here.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
- **Cross-Platform**: Works seamlessly on both macOS and Windows environments.
|
|
14
|
-
- **Ruby-Powered**: Enjoy the elegance and simplicity of Ruby while crafting creative projects.
|
|
15
|
-
- **Extensible and Open**: Modify and extend the library to fit your unique needs.
|
|
13
|
+
### 🔄 Where to Contribute?
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
All development happens in our [xord/all](https://github.com/xord/all) monorepo, which contains all our main libraries.
|
|
16
|
+
If you'd like to contribute, please submit your changes there.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
For more details, check out our [Contribution Guidelines](./CONTRIBUTING.md).
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
Thanks for your support! 🙌
|
|
21
|
+
|
|
22
|
+
## 🚀 About
|
|
23
|
+
|
|
24
|
+
**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.
|
|
25
|
+
|
|
26
|
+
Under the hood it builds on the rest of the `xord/*` family — Reight's runtime is essentially [RubySketch](https://github.com/xord/rubysketch) (and [Processing](https://github.com/xord/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.
|
|
27
|
+
|
|
28
|
+
A project is just a directory of plain files:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
mygame/
|
|
32
|
+
├── project.json # screen size, font, file names, ...
|
|
33
|
+
├── game.rb # your game code (uses Reight's top-level API)
|
|
34
|
+
├── chips.png # tileset image
|
|
35
|
+
├── chips.json # tile metadata (shapes, sensors, ...)
|
|
36
|
+
├── maps.json # tile-map data (chunked)
|
|
37
|
+
└── sounds.json # sound data
|
|
23
38
|
```
|
|
24
39
|
|
|
25
|
-
|
|
40
|
+
## 📋 Requirements
|
|
26
41
|
|
|
42
|
+
- Ruby **3.0.0** or later
|
|
43
|
+
- All the runtime requirements of [Reflex](https://github.com/xord/reflex) (Rays, Rucy, Xot, plus the platform GUI backend — AppKit / UIKit / Win32 / SDL2 — and OpenGL)
|
|
44
|
+
- The dependent gems are installed automatically: `xot`, `rucy`, `beeps`, `rays`, `reflexion`, `processing`, `rubysketch`
|
|
45
|
+
|
|
46
|
+
There is no native C/C++ extension in this gem; the heavy lifting is done by the underlying gems' extensions.
|
|
47
|
+
|
|
48
|
+
## 📦 Installation
|
|
49
|
+
|
|
50
|
+
Add this line to your Gemfile:
|
|
27
51
|
```ruby
|
|
28
52
|
gem 'reight'
|
|
29
53
|
```
|
|
30
54
|
|
|
31
|
-
Then
|
|
55
|
+
Then install:
|
|
56
|
+
```bash
|
|
57
|
+
$ bundle install
|
|
58
|
+
```
|
|
32
59
|
|
|
60
|
+
Or install it directly:
|
|
33
61
|
```bash
|
|
34
|
-
|
|
62
|
+
$ gem install reight
|
|
35
63
|
```
|
|
36
64
|
|
|
37
|
-
|
|
65
|
+
The gem also installs a `r8` command-line tool used to run and edit projects.
|
|
66
|
+
|
|
67
|
+
## ▶️ The `r8` command
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ r8 [DIR] # run the project in DIR (default: current directory)
|
|
71
|
+
$ r8 --edit [DIR] # open the project in the built-in editor
|
|
72
|
+
$ r8 --help # show all options
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`DIR` is the project directory described above. If it does not contain a `project.json`, defaults are used.
|
|
76
|
+
|
|
77
|
+
### Built-in editor screens
|
|
78
|
+
|
|
79
|
+
When launched with `--edit`, the engine adds these tabs alongside the game runner:
|
|
80
|
+
|
|
81
|
+
| Editor | Purpose | Tools (`lib/reight/app/<name>/`) |
|
|
82
|
+
| ------------ | ---------------------------------------------------------------- | -------------------------------- |
|
|
83
|
+
| **Sprite** | Pixel-art editor for the chip / tileset image (`chips.png`) | brush, fill, color picker, line, rect / shape, select |
|
|
84
|
+
| **Map** | Chunk-based tile-map editor | brush, line, rect |
|
|
85
|
+
| **Sound** | Waveform-based sound editor | brush, eraser |
|
|
86
|
+
|
|
87
|
+
The currently active tab is switched from the top navigator bar.
|
|
88
|
+
|
|
89
|
+
## 📚 What's Provided
|
|
90
|
+
|
|
91
|
+
`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.
|
|
92
|
+
|
|
93
|
+
### Reight-specific API
|
|
94
|
+
|
|
95
|
+
| API | Purpose |
|
|
96
|
+
| -------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
97
|
+
| `project` | The active `Reight::Project` — accessors for `chips`, `maps`, `sounds`, project paths, font, etc. |
|
|
98
|
+
| `Reight::Sprite` | A subclass of `RubySketch::Sprite` carrying an optional `chip` and a per-instance `props` hash; default sprite class returned by `createSprite` inside Reight |
|
|
99
|
+
| `Reight::Chip` | A single tile from the tileset — `id`, position / size in `chips.png`, optional collision shape and sensor flag |
|
|
100
|
+
| `Reight::Map` | Chunk-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 |
|
|
101
|
+
| `Reight::Sound` | Persistent sound asset, edited by the Sound editor |
|
|
102
|
+
| `Reight::Project` | Loads and saves the JSON / PNG files described above |
|
|
103
|
+
|
|
104
|
+
### Constants on `Reight::App`
|
|
105
|
+
|
|
106
|
+
| Constant | Value | Meaning |
|
|
107
|
+
| ------------------- | ---------- | -------------------------------------------------------------------- |
|
|
108
|
+
| `SCREEN_WIDTH` | `400` | Fixed framebuffer width |
|
|
109
|
+
| `SCREEN_HEIGHT` | `224` | Fixed framebuffer height |
|
|
110
|
+
| `PALETTE_COLORS` | 32 entries | Default 32-color hex palette (transparent first, then a PICO-8-flavored set) |
|
|
38
111
|
|
|
39
|
-
|
|
112
|
+
The window opens at `3×` the framebuffer size by default; the framebuffer is upscaled with no smoothing for a crisp pixel-art look.
|
|
113
|
+
|
|
114
|
+
## 💡 Usage
|
|
115
|
+
|
|
116
|
+
### Minimal `game.rb`
|
|
40
117
|
|
|
41
118
|
```ruby
|
|
42
|
-
# Create a window and draw something
|
|
43
119
|
draw do
|
|
44
120
|
background 0
|
|
45
|
-
|
|
46
|
-
|
|
121
|
+
fill 1
|
|
122
|
+
text 'hello, reight!', 10, 100
|
|
47
123
|
end
|
|
48
124
|
```
|
|
49
125
|
|
|
50
|
-
Run
|
|
126
|
+
Run it from the project directory:
|
|
51
127
|
|
|
52
128
|
```bash
|
|
53
|
-
$
|
|
129
|
+
$ r8 .
|
|
54
130
|
```
|
|
55
131
|
|
|
56
|
-
|
|
132
|
+
### Move a sprite with the cursor keys
|
|
133
|
+
|
|
134
|
+
```ruby
|
|
135
|
+
player = createSprite 200, 112, 8, 8
|
|
136
|
+
|
|
137
|
+
player.update do
|
|
138
|
+
player.x += 1 if key_is_down(RIGHT)
|
|
139
|
+
player.x -= 1 if key_is_down(LEFT)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
draw do
|
|
143
|
+
background 0
|
|
144
|
+
sprite player
|
|
145
|
+
end
|
|
146
|
+
```
|
|
57
147
|
|
|
58
|
-
|
|
148
|
+
### Draw the first map of the project
|
|
59
149
|
|
|
60
|
-
|
|
150
|
+
```ruby
|
|
151
|
+
draw do
|
|
152
|
+
background 0
|
|
153
|
+
$sprites ||= project.maps.first.to_sprites
|
|
154
|
+
sprite *$sprites
|
|
155
|
+
end
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
(Open `r8 --edit .` first to draw the map, then run `r8 .` to play it.)
|
|
159
|
+
|
|
160
|
+
### Use chip properties
|
|
161
|
+
|
|
162
|
+
Chips have a `props` hash you can read from your game code:
|
|
163
|
+
|
|
164
|
+
```ruby
|
|
165
|
+
$sprites ||= project.maps.first.to_sprites.each do |sp|
|
|
166
|
+
sp.dynamic = true if sp.chip.props[:dynamic]
|
|
167
|
+
end
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 🛠️ Development
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
$ rake test # run the test suite
|
|
174
|
+
$ rake doc # generate YARD docs
|
|
175
|
+
$ rake # default tasks
|
|
176
|
+
```
|
|
61
177
|
|
|
62
|
-
|
|
178
|
+
In the [`xord/all`](https://github.com/xord/all) monorepo you can scope by module, e.g. `rake reight test`.
|
|
63
179
|
|
|
64
|
-
|
|
180
|
+
There is also a WASM build pipeline under [`wasm/`](./wasm) that packages the engine and your project for the browser via Emscripten + ruby.wasm.
|
|
65
181
|
|
|
66
|
-
|
|
182
|
+
## 📜 License
|
|
67
183
|
|
|
68
|
-
|
|
184
|
+
**Reight** is licensed under the MIT License.
|
|
185
|
+
See the [LICENSE](./LICENSE) file for details.
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
data/lib/reight/extension.rb
CHANGED
data/reight.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
ext = Reight::Extension
|
|
13
|
-
name = ext.name
|
|
13
|
+
name = ext.name true
|
|
14
14
|
rdocs = glob.call *%w[README]
|
|
15
15
|
|
|
16
16
|
s.name = name
|
|
@@ -25,13 +25,13 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
|
27
27
|
|
|
28
|
-
s.add_dependency 'xot', '~> 0.3.
|
|
29
|
-
s.add_dependency 'rucy', '~> 0.3.
|
|
30
|
-
s.add_dependency 'beeps', '~> 0.3.
|
|
31
|
-
s.add_dependency 'rays', '~> 0.3.
|
|
32
|
-
s.add_dependency 'reflexion', '~> 0.
|
|
33
|
-
s.add_dependency 'processing', '~> 1.
|
|
34
|
-
s.add_dependency 'rubysketch', '~> 0.
|
|
28
|
+
s.add_dependency 'xot', '~> 0.3.13'
|
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.13'
|
|
30
|
+
s.add_dependency 'beeps', '~> 0.3.13'
|
|
31
|
+
s.add_dependency 'rays', '~> 0.3.13'
|
|
32
|
+
s.add_dependency 'reflexion', '~> 0.4.0'
|
|
33
|
+
s.add_dependency 'processing', '~> 1.2.0'
|
|
34
|
+
s.add_dependency 'rubysketch', '~> 0.8.0'
|
|
35
35
|
|
|
36
36
|
s.files = `git ls-files`.split $/
|
|
37
37
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/wasm/.bundle/config
ADDED
data/wasm/.gitignore
ADDED
data/wasm/Gemfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem 'rake'
|
|
4
|
+
gem 'ruby_wasm', '~> 2.9.4'
|
|
5
|
+
|
|
6
|
+
gem 'xot', path: '../../xot'
|
|
7
|
+
gem 'rucy', path: '../../rucy'
|
|
8
|
+
gem 'beeps', path: '../../beeps'
|
|
9
|
+
gem 'rays', path: '../../rays'
|
|
10
|
+
gem 'reflexion', path: '../../reflex'
|
|
11
|
+
gem 'processing', path: '../../processing'
|
|
12
|
+
gem 'rubysketch', path: '../../rubysketch'
|
|
13
|
+
gem 'reight', path: '../../reight'
|
data/wasm/Gemfile.lock
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../../beeps
|
|
3
|
+
specs:
|
|
4
|
+
beeps (0.3.11)
|
|
5
|
+
rucy (~> 0.3.11)
|
|
6
|
+
xot (~> 0.3.11)
|
|
7
|
+
|
|
8
|
+
PATH
|
|
9
|
+
remote: ../../processing
|
|
10
|
+
specs:
|
|
11
|
+
processing (1.1.17)
|
|
12
|
+
rays (~> 0.3.11)
|
|
13
|
+
reflexion (~> 0.3.14)
|
|
14
|
+
rexml
|
|
15
|
+
rucy (~> 0.3.11)
|
|
16
|
+
xot (~> 0.3.11)
|
|
17
|
+
|
|
18
|
+
PATH
|
|
19
|
+
remote: ../../rays
|
|
20
|
+
specs:
|
|
21
|
+
rays (0.3.11)
|
|
22
|
+
rucy (~> 0.3.11)
|
|
23
|
+
xot (~> 0.3.11)
|
|
24
|
+
|
|
25
|
+
PATH
|
|
26
|
+
remote: ../../reflex
|
|
27
|
+
specs:
|
|
28
|
+
reflexion (0.3.14)
|
|
29
|
+
rays (~> 0.3.11)
|
|
30
|
+
rucy (~> 0.3.11)
|
|
31
|
+
xot (~> 0.3.11)
|
|
32
|
+
|
|
33
|
+
PATH
|
|
34
|
+
remote: ../../rubysketch
|
|
35
|
+
specs:
|
|
36
|
+
rubysketch (0.7.18)
|
|
37
|
+
beeps (~> 0.3.11)
|
|
38
|
+
processing (~> 1.1.17)
|
|
39
|
+
rays (~> 0.3.11)
|
|
40
|
+
reflexion (~> 0.3.14)
|
|
41
|
+
rucy (~> 0.3.11)
|
|
42
|
+
xot (~> 0.3.11)
|
|
43
|
+
|
|
44
|
+
PATH
|
|
45
|
+
remote: ../../rucy
|
|
46
|
+
specs:
|
|
47
|
+
rucy (0.3.11)
|
|
48
|
+
xot (~> 0.3.11)
|
|
49
|
+
|
|
50
|
+
PATH
|
|
51
|
+
remote: ../../xot
|
|
52
|
+
specs:
|
|
53
|
+
xot (0.3.11)
|
|
54
|
+
|
|
55
|
+
PATH
|
|
56
|
+
remote: ..
|
|
57
|
+
specs:
|
|
58
|
+
reight (0.1.17)
|
|
59
|
+
beeps (~> 0.3.11)
|
|
60
|
+
processing (~> 1.1.17)
|
|
61
|
+
rays (~> 0.3.11)
|
|
62
|
+
reflexion (~> 0.3.14)
|
|
63
|
+
rubysketch (~> 0.7.18)
|
|
64
|
+
rucy (~> 0.3.11)
|
|
65
|
+
xot (~> 0.3.11)
|
|
66
|
+
|
|
67
|
+
GEM
|
|
68
|
+
remote: https://rubygems.org/
|
|
69
|
+
specs:
|
|
70
|
+
logger (1.7.0)
|
|
71
|
+
rake (13.4.2)
|
|
72
|
+
rexml (3.4.4)
|
|
73
|
+
ruby_wasm (2.9.4-aarch64-linux)
|
|
74
|
+
logger
|
|
75
|
+
ruby_wasm (2.9.4-arm64-darwin)
|
|
76
|
+
logger
|
|
77
|
+
|
|
78
|
+
PLATFORMS
|
|
79
|
+
aarch64-linux-gnu
|
|
80
|
+
arm64-darwin-23
|
|
81
|
+
|
|
82
|
+
DEPENDENCIES
|
|
83
|
+
beeps!
|
|
84
|
+
processing!
|
|
85
|
+
rake
|
|
86
|
+
rays!
|
|
87
|
+
reflexion!
|
|
88
|
+
reight!
|
|
89
|
+
ruby_wasm (~> 2.9.4)
|
|
90
|
+
rubysketch!
|
|
91
|
+
rucy!
|
|
92
|
+
xot!
|
|
93
|
+
|
|
94
|
+
BUNDLED WITH
|
|
95
|
+
2.4.20
|
data/wasm/Rakefile
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
%w[xot]
|
|
2
|
+
.map {|s| File.expand_path "../../#{s}/lib", __dir__}
|
|
3
|
+
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
|
4
|
+
|
|
5
|
+
require 'xot/rake/util'
|
|
6
|
+
|
|
7
|
+
include Xot::Rake
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def envs()
|
|
11
|
+
{
|
|
12
|
+
CC: 'emcc',
|
|
13
|
+
CXX: 'em++',
|
|
14
|
+
AR: 'emar',
|
|
15
|
+
RANLIB: 'emranlib',
|
|
16
|
+
CPPFLAGS: '-sUSE_SDL=2',
|
|
17
|
+
}.map {|k, v| "#{k}=#{v}"}.join ' '
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
NAME = 'reight'
|
|
22
|
+
|
|
23
|
+
ROOT_DIR = File.expand_path '../..', __dir__
|
|
24
|
+
BUNDLE_DIR = 'vendor/bundle'
|
|
25
|
+
DATA_DIR = '.data'
|
|
26
|
+
OUT_DIR = 'output'
|
|
27
|
+
|
|
28
|
+
GEMS = Dir.glob("#{ROOT_DIR}/*/*.gemspec").map {File.basename File.dirname _1}
|
|
29
|
+
GEM_SRCS = GEMS.map {Dir.glob "#{ROOT_DIR}/#{_1}/**/*.{h,hpp,c,cpp,m,mm,rb}"}.flatten
|
|
30
|
+
|
|
31
|
+
OUT_WASM = "#{OUT_DIR}/ruby.wasm"
|
|
32
|
+
OUT_JS = "#{OUT_DIR}/#{NAME}.js"
|
|
33
|
+
OUT_DATA = "#{OUT_DIR}/#{NAME}.data"
|
|
34
|
+
OUT_LIB_JS = "#{OUT_DIR}/#{NAME}lib.js"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
task :default => :build
|
|
38
|
+
|
|
39
|
+
task :clean do
|
|
40
|
+
Dir.chdir ROOT_DIR do
|
|
41
|
+
sh %( rake clean )
|
|
42
|
+
end
|
|
43
|
+
sh %( rm -rf build rubies #{OUT_DIR} #{BUNDLE_DIR} #{DATA_DIR} )
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
task :clobber => :clean do
|
|
47
|
+
Dir.chdir ROOT_DIR do
|
|
48
|
+
sh %( rake clobber )
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
task :build => [OUT_WASM, OUT_DATA]
|
|
53
|
+
|
|
54
|
+
file OUT_DATA => OUT_WASM do
|
|
55
|
+
emroot = `em-config EMSCRIPTEN_ROOT`.strip
|
|
56
|
+
raise 'emscripten not found' if emroot.empty?
|
|
57
|
+
|
|
58
|
+
packager = "#{emroot}/tools/file_packager"
|
|
59
|
+
opts = [
|
|
60
|
+
"--preload '#{DATA_DIR}@/'",
|
|
61
|
+
"--export-name=globalThis.__ruby_module"
|
|
62
|
+
]
|
|
63
|
+
loader = `#{packager} #{OUT_DATA} #{opts.join ' '}`
|
|
64
|
+
raise 'file_packager failed' if !$?.success? || loader.empty?
|
|
65
|
+
|
|
66
|
+
File.write OUT_LIB_JS, "export function loadReightLib() {#{loader}};"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
file OUT_WASM => [BUNDLE_DIR, OUT_DIR] + GEM_SRCS do
|
|
70
|
+
sh %( rm -rf #{DATA_DIR} )
|
|
71
|
+
|
|
72
|
+
GEMS.each do |gem|
|
|
73
|
+
filter_file "#{ROOT_DIR}/#{gem}/#{gem}.gemspec" do |s|
|
|
74
|
+
s.sub(/^(.*\.\s*extensions.*)$/) {$1.sub 'Rakefile', "ext/#{gem}/extconf.rb"}
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
ldflags = %W[
|
|
79
|
+
-sASYNCIFY_STACK_SIZE=#{1024 * 1024 * 4}
|
|
80
|
+
-sNO_DISABLE_EXCEPTION_CATCHING
|
|
81
|
+
-sFORCE_FILESYSTEM
|
|
82
|
+
-sUSE_SDL=2
|
|
83
|
+
-sUSE_SDL_TTF=2
|
|
84
|
+
-sALLOW_MEMORY_GROWTH=1
|
|
85
|
+
-sINITIAL_MEMORY=#{1024 * 1024 * 64}
|
|
86
|
+
-sEXPORTED_RUNTIME_METHODS=ccall,cwrap,UTF8ToString,stringToUTF8,FS
|
|
87
|
+
-sASSERTIONS=1
|
|
88
|
+
-fexceptions
|
|
89
|
+
].reject {_1 =~ /^\s*#/}
|
|
90
|
+
envs = "RUBY_WASM_EMCC_LDFLAGS=' #{ldflags.join ' '}'"
|
|
91
|
+
sysopts = '--log-level debug'
|
|
92
|
+
opts = "--target wasm32-unknown-emscripten --dest_dir #{DATA_DIR} --remake -o #{OUT_JS}"
|
|
93
|
+
sh %( #{envs} bundle exec rbwasm #{sysopts} build #{opts} )
|
|
94
|
+
|
|
95
|
+
roots = Dir.glob('rubies/ruby-*-wasm*-*-emscripten-full-*')
|
|
96
|
+
.select {File.directory? _1}
|
|
97
|
+
raise "expected 1 root, got #{roots.size}" if roots.size != 1
|
|
98
|
+
sh %( cp -f #{roots.first}/usr/local/bin/ruby.wasm #{OUT_WASM} )
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
file BUNDLE_DIR do
|
|
102
|
+
sh %( bundle install )
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
directory OUT_DIR
|
|
106
|
+
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: reight
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- xordog
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: xot
|
|
@@ -16,98 +16,98 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.3.
|
|
19
|
+
version: 0.3.13
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.3.
|
|
26
|
+
version: 0.3.13
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rucy
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.3.
|
|
33
|
+
version: 0.3.13
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.3.
|
|
40
|
+
version: 0.3.13
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: beeps
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.3.
|
|
47
|
+
version: 0.3.13
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.3.
|
|
54
|
+
version: 0.3.13
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rays
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0.3.
|
|
61
|
+
version: 0.3.13
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0.3.
|
|
68
|
+
version: 0.3.13
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: reflexion
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
75
|
+
version: 0.4.0
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
82
|
+
version: 0.4.0
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: processing
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 1.
|
|
89
|
+
version: 1.2.0
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 1.
|
|
96
|
+
version: 1.2.0
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: rubysketch
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 0.
|
|
103
|
+
version: 0.8.0
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 0.
|
|
110
|
+
version: 0.8.0
|
|
111
111
|
description: A Retro Game Engine for Ruby.
|
|
112
112
|
email: xordog@gmail.com
|
|
113
113
|
executables:
|
|
@@ -120,6 +120,7 @@ files:
|
|
|
120
120
|
- ".github/workflows/tag.yml"
|
|
121
121
|
- ".github/workflows/test.yml"
|
|
122
122
|
- ".github/workflows/utils.rb"
|
|
123
|
+
- ".github/workflows/wasm.yml"
|
|
123
124
|
- ".gitignore"
|
|
124
125
|
- CLAUDE.md
|
|
125
126
|
- CONTRIBUTING.md
|
|
@@ -181,6 +182,11 @@ files:
|
|
|
181
182
|
- test/test_map.rb
|
|
182
183
|
- test/test_map_chunk.rb
|
|
183
184
|
- test/test_sprite.rb
|
|
185
|
+
- wasm/.bundle/config
|
|
186
|
+
- wasm/.gitignore
|
|
187
|
+
- wasm/Gemfile
|
|
188
|
+
- wasm/Gemfile.lock
|
|
189
|
+
- wasm/Rakefile
|
|
184
190
|
homepage: https://github.com/xord/reight
|
|
185
191
|
licenses:
|
|
186
192
|
- MIT
|