reight 0.1.18 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1751996f1a274e567963f26fcd4b1130d2f23b33380f1757ee7caf4e26f36b36
4
- data.tar.gz: 464e9a90cc0021ccc0437191d6ad0455f4ae7f0b4ccc325671546003d25631f0
3
+ metadata.gz: 65c71b399c42f92fb4c05e26480b518b9cbbd8f3e91c3794cf2f3ee55d1a19bf
4
+ data.tar.gz: 163991b67c1cad80ff364717ab15d36c9b17a11ee16bb1810cb296df9273c324
5
5
  SHA512:
6
- metadata.gz: ac07bacf3ca5e59c3537976bc305f4b1434e53cccee9abc34c2d3d10e0f1de7c13a45a61ba8951d85964eec80bd90ec17f83c2d56e204b162f9d40be811f9ab0
7
- data.tar.gz: b5f5bbba9ca3e19fd847c7f8510049e48af988bb3492c747b7b45ffbea46657d65d227c8a6fb146ae601027a6bc77be7bab8dda6b48ef4478bd5b870733ff475
6
+ metadata.gz: 5af249900681707474780ab12f681a845b485f28e81c4ba507e9f39a87ebd607ba588e0f37e8927439855816e2acfed7d960d29af493a4e5dc54fd8ec5266154
7
+ data.tar.gz: 67aafaaddfd9e977c7da287c88b88d3822507addc34121e30060b390538ba2baadbc51cb07045a74d92b2231eb5e65357aa916e3dbd17692dd7feba3bfd5c534
@@ -36,23 +36,9 @@ jobs:
36
36
  echo path=$(ruby -e 'print Dir.glob("*.gem").first') >> $GITHUB_OUTPUT
37
37
 
38
38
  - name: create github release
39
- id: release
40
- uses: actions/create-release@v1
41
39
  env:
42
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43
- with:
44
- tag_name: ${{ github.ref }}
45
- release_name: ${{ github.ref }}
46
-
47
- - name: upload to github release
48
- uses: actions/upload-release-asset@v1
49
- env:
50
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51
- with:
52
- upload_url: ${{ steps.release.outputs.upload_url }}
53
- asset_path: ./${{ steps.gem.outputs.path }}
54
- asset_name: ${{ steps.gem.outputs.path }}
55
- 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 }}
56
42
 
57
43
  - name: upload to rubygems
58
44
  env:
@@ -6,6 +6,7 @@ on:
6
6
 
7
7
  permissions:
8
8
  contents: write
9
+ id-token: write
9
10
 
10
11
  jobs:
11
12
  wasm:
@@ -23,6 +24,12 @@ jobs:
23
24
  - name: checkout monorepo
24
25
  run: ruby -I.github/workflows -rutils -e 'abort unless checkout_monorepo'
25
26
 
27
+ - name: setup node
28
+ uses: actions/setup-node@v4
29
+ with:
30
+ node-version: 20
31
+ registry-url: https://registry.npmjs.org
32
+
26
33
  - name: install emscripten
27
34
  uses: mymindstorm/setup-emsdk@v14
28
35
  with:
@@ -35,3 +42,6 @@ jobs:
35
42
  env:
36
43
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37
44
  run: ruby -I.github/workflows -rutils -e 'release(*Dir.glob("../all/reight/wasm/output/*"))'
45
+
46
+ - name: publish to npm
47
+ run: cd ../all/reight/wasm && rake publish
data/ChangeLog.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # reight ChangeLog
2
2
 
3
3
 
4
+ ## [v0.2.1] - 2026-05-20
5
+
6
+ - Add npm publish to WASM release workflow
7
+ - Add test server task for local WASM development
8
+ - Rename wasm.yml to release-wasm.yml
9
+
10
+
11
+ ## [v0.2.0] - 2026-05-17
12
+
13
+ - [BREAKING] Wheel Y delta now follows top-left origin convention (from reflex)
14
+
15
+ - Rewrite README.md
16
+ - CI: Migrate release-gem.yml from actions/create-release to gh release create
17
+
18
+
4
19
  ## [v0.1.18] - 2026-05-10
5
20
 
6
21
  - Support WebAssembly
data/README.md CHANGED
@@ -1,68 +1,185 @@
1
- # Reight - A Retro Game Engine for Ruby
1
+ # Reight - A retro game engine for Ruby
2
2
 
3
3
  [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/xord/reight)
4
4
  ![License](https://img.shields.io/github/license/xord/reight)
5
5
  ![Build Status](https://github.com/xord/reight/actions/workflows/test.yml/badge.svg)
6
6
  ![Gem Version](https://badge.fury.io/rb/reight.svg)
7
7
 
8
- Reight is an open-source Ruby library inspired by the powerful [Processing](https://processing.org/) API, designed to make creative coding accessible and enjoyable for everyone. With support for both Mac and Windows, this library brings the joy of visual programming to Ruby developers.
8
+ ## ⚠️ Notice
9
9
 
10
- ## Features
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
- - **Processing API Compatibility**: Leverage the well-known Processing API to create stunning visuals, animations, and interactive applications using Ruby.
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
- ## Installation
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
- Install the gem via RubyGems:
18
+ For more details, check out our [Contribution Guidelines](./CONTRIBUTING.md).
20
19
 
21
- ```bash
22
- gem install reight
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
- Or add it to your Gemfile:
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 run:
55
+ Then install:
56
+ ```bash
57
+ $ bundle install
58
+ ```
32
59
 
60
+ Or install it directly:
33
61
  ```bash
34
- bundle install
62
+ $ gem install reight
35
63
  ```
36
64
 
37
- ## Getting Started
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
- Here’s a simple example to get you started:
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
- $sprites ||= project.maps.first.map(&:to_sprite)
46
- sprite $sprites
121
+ fill 1
122
+ text 'hello, reight!', 10, 100
47
123
  end
48
124
  ```
49
125
 
50
- Run the script and watch your window come to life!
126
+ Run it from the project directory:
51
127
 
52
128
  ```bash
53
- $ bundle exec r8 --edit .
129
+ $ r8 .
54
130
  ```
55
131
 
56
- You can find example projects in [xord/reight-examples](https://github.com/xord/reight-examples).
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
- ## Documentation
148
+ ### Draw the first map of the project
59
149
 
60
- Comprehensive documentation and guides can be found [here](https://www.rubydoc.info/gems/reight/).
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
- ## License
178
+ In the [`xord/all`](https://github.com/xord/all) monorepo you can scope by module, e.g. `rake reight test`.
63
179
 
64
- This project is licensed under the [MIT License](LICENSE).
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
- Happy coding with Ruby and Processing!
184
+ **Reight** is licensed under the MIT License.
185
+ See the [LICENSE](./LICENSE) file for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.18
1
+ 0.2.1
data/reight.gemspec CHANGED
@@ -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.12'
29
- s.add_dependency 'rucy', '~> 0.3.12'
30
- s.add_dependency 'beeps', '~> 0.3.12'
31
- s.add_dependency 'rays', '~> 0.3.12'
32
- s.add_dependency 'reflexion', '~> 0.3.15'
33
- s.add_dependency 'processing', '~> 1.1.18'
34
- s.add_dependency 'rubysketch', '~> 0.7.19'
28
+ s.add_dependency 'xot', '~> 0.3.13'
29
+ s.add_dependency 'rucy', '~> 0.3.13'
30
+ s.add_dependency 'beeps', '~> 0.3.14'
31
+ s.add_dependency 'rays', '~> 0.3.14'
32
+ s.add_dependency 'reflexion', '~> 0.4.1'
33
+ s.add_dependency 'processing', '~> 1.2.1'
34
+ s.add_dependency 'rubysketch', '~> 0.8.1'
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/.gitignore CHANGED
@@ -2,3 +2,4 @@ build/
2
2
  rubies/
3
3
  .data/
4
4
  output/
5
+ test/
data/wasm/Gemfile.lock CHANGED
@@ -1,68 +1,68 @@
1
1
  PATH
2
2
  remote: ../../beeps
3
3
  specs:
4
- beeps (0.3.11)
5
- rucy (~> 0.3.11)
6
- xot (~> 0.3.11)
4
+ beeps (0.3.13)
5
+ rucy (~> 0.3.13)
6
+ xot (~> 0.3.13)
7
7
 
8
8
  PATH
9
9
  remote: ../../processing
10
10
  specs:
11
- processing (1.1.17)
12
- rays (~> 0.3.11)
13
- reflexion (~> 0.3.14)
11
+ processing (1.2.0)
12
+ rays (~> 0.3.13)
13
+ reflexion (~> 0.4.0)
14
14
  rexml
15
- rucy (~> 0.3.11)
16
- xot (~> 0.3.11)
15
+ rucy (~> 0.3.13)
16
+ xot (~> 0.3.13)
17
17
 
18
18
  PATH
19
19
  remote: ../../rays
20
20
  specs:
21
- rays (0.3.11)
22
- rucy (~> 0.3.11)
23
- xot (~> 0.3.11)
21
+ rays (0.3.13)
22
+ rucy (~> 0.3.13)
23
+ xot (~> 0.3.13)
24
24
 
25
25
  PATH
26
26
  remote: ../../reflex
27
27
  specs:
28
- reflexion (0.3.14)
29
- rays (~> 0.3.11)
30
- rucy (~> 0.3.11)
31
- xot (~> 0.3.11)
28
+ reflexion (0.4.0)
29
+ rays (~> 0.3.13)
30
+ rucy (~> 0.3.13)
31
+ xot (~> 0.3.13)
32
32
 
33
33
  PATH
34
34
  remote: ../../rubysketch
35
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)
36
+ rubysketch (0.8.0)
37
+ beeps (~> 0.3.13)
38
+ processing (~> 1.2.0)
39
+ rays (~> 0.3.13)
40
+ reflexion (~> 0.4.0)
41
+ rucy (~> 0.3.13)
42
+ xot (~> 0.3.13)
43
43
 
44
44
  PATH
45
45
  remote: ../../rucy
46
46
  specs:
47
- rucy (0.3.11)
48
- xot (~> 0.3.11)
47
+ rucy (0.3.13)
48
+ xot (~> 0.3.13)
49
49
 
50
50
  PATH
51
51
  remote: ../../xot
52
52
  specs:
53
- xot (0.3.11)
53
+ xot (0.3.13)
54
54
 
55
55
  PATH
56
56
  remote: ..
57
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)
58
+ reight (0.2.0)
59
+ beeps (~> 0.3.13)
60
+ processing (~> 1.2.0)
61
+ rays (~> 0.3.13)
62
+ reflexion (~> 0.4.0)
63
+ rubysketch (~> 0.8.0)
64
+ rucy (~> 0.3.13)
65
+ xot (~> 0.3.13)
66
66
 
67
67
  GEM
68
68
  remote: https://rubygems.org/
@@ -78,6 +78,7 @@ GEM
78
78
  PLATFORMS
79
79
  aarch64-linux-gnu
80
80
  arm64-darwin-23
81
+ arm64-darwin-24
81
82
 
82
83
  DEPENDENCIES
83
84
  beeps!
data/wasm/Rakefile CHANGED
@@ -1,23 +1,15 @@
1
- %w[xot]
1
+ %w[xot reight]
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
+ require 'json'
6
+ require 'erb'
5
7
  require 'xot/rake/util'
8
+ require 'reight/extension'
6
9
 
7
10
  include Xot::Rake
8
11
 
9
12
 
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
13
  NAME = 'reight'
22
14
 
23
15
  ROOT_DIR = File.expand_path '../..', __dir__
@@ -32,15 +24,16 @@ OUT_WASM = "#{OUT_DIR}/ruby.wasm"
32
24
  OUT_JS = "#{OUT_DIR}/#{NAME}.js"
33
25
  OUT_DATA = "#{OUT_DIR}/#{NAME}.data"
34
26
  OUT_LIB_JS = "#{OUT_DIR}/#{NAME}lib.js"
27
+ OUT_FILES = [OUT_WASM, OUT_JS, OUT_DATA, OUT_LIB_JS]
35
28
 
36
29
 
37
30
  task :default => :build
38
31
 
39
- task :clean do
32
+ task :clean => 'test:clean' do
40
33
  Dir.chdir ROOT_DIR do
41
34
  sh %( rake clean )
42
35
  end
43
- sh %( rm -rf build rubies #{OUT_DIR} #{BUNDLE_DIR} #{DATA_DIR} )
36
+ sh %( rm -rf build rubies #{BUNDLE_DIR} #{DATA_DIR} #{OUT_DIR} )
44
37
  end
45
38
 
46
39
  task :clobber => :clean do
@@ -49,7 +42,19 @@ task :clobber => :clean do
49
42
  end
50
43
  end
51
44
 
52
- task :build => [OUT_WASM, OUT_DATA]
45
+ task :build => OUT_DATA
46
+
47
+ task :publish => :build do
48
+ File.write "#{OUT_DIR}/package.json", JSON.pretty_generate(
49
+ name: 'reight-wasm',
50
+ version: Reight::Extension.version,
51
+ description: 'Reight game engine WASM build',
52
+ files: OUT_FILES.map {File.basename _1},
53
+ repository: {type: 'git', url: 'git+https://github.com/xord/reight.git'},
54
+ license: 'MIT'
55
+ )
56
+ sh %( cd #{OUT_DIR} && npm publish --provenance )
57
+ end
53
58
 
54
59
  file OUT_DATA => OUT_WASM do
55
60
  emroot = `em-config EMSCRIPTEN_ROOT`.strip
@@ -69,28 +74,35 @@ end
69
74
  file OUT_WASM => [BUNDLE_DIR, OUT_DIR] + GEM_SRCS do
70
75
  sh %( rm -rf #{DATA_DIR} )
71
76
 
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"}
77
+ backups = {}
78
+ begin
79
+ GEMS.each do |gem|
80
+ path = "#{ROOT_DIR}/#{gem}/#{gem}.gemspec"
81
+ filter_file path do |s|
82
+ backups[path] = s
83
+ s.sub(/^(.*\.\s*extensions.*)$/) {$1.sub 'Rakefile', "ext/#{gem}/extconf.rb"}
84
+ end
75
85
  end
76
- end
77
86
 
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} )
87
+ ldflags = %W[
88
+ -sASYNCIFY_STACK_SIZE=#{1024 * 1024 * 4}
89
+ -sNO_DISABLE_EXCEPTION_CATCHING
90
+ -sFORCE_FILESYSTEM
91
+ -sUSE_SDL=2
92
+ -sUSE_SDL_TTF=2
93
+ -sALLOW_MEMORY_GROWTH=1
94
+ -sINITIAL_MEMORY=#{1024 * 1024 * 64}
95
+ -sEXPORTED_RUNTIME_METHODS=ccall,cwrap,UTF8ToString,stringToUTF8,FS
96
+ -sASSERTIONS=1
97
+ -fexceptions
98
+ ].reject {_1 =~ /^\s*#/}
99
+ envs = "RUBY_WASM_EMCC_LDFLAGS=' #{ldflags.join ' '}'"
100
+ sysopts = '--log-level debug'
101
+ opts = "--target wasm32-unknown-emscripten --dest_dir #{DATA_DIR} --remake -o #{OUT_JS}"
102
+ sh %( #{envs} bundle exec rbwasm #{sysopts} build #{opts} )
103
+ ensure
104
+ backups.each {|path, s| File.write path, s}
105
+ end
94
106
 
95
107
  roots = Dir.glob('rubies/ruby-*-wasm*-*-emscripten-full-*')
96
108
  .select {File.directory? _1}
@@ -104,3 +116,76 @@ end
104
116
 
105
117
  directory OUT_DIR
106
118
 
119
+
120
+ namespace :test do
121
+ template_dir = 'template'
122
+ test_dir = 'test'
123
+ main = "#{test_dir}/test.rb"
124
+ erbs = {
125
+ "#{test_dir}/index.html" => "#{template_dir}/index.html.erb"
126
+ }
127
+ wasm_files = OUT_FILES.each.with_object({}) {|out, hash|
128
+ hash["#{test_dir}/#{File.basename out}"] = out
129
+ }
130
+
131
+ task :clean do
132
+ sh %( rm -rf #{test_dir} )
133
+ end
134
+
135
+ task :serve => [main] + erbs.keys + wasm_files.keys do
136
+ require 'webrick'
137
+ WEBrick::HTTPServer.new(Port: 8080, DocumentRoot: test_dir).start
138
+ end
139
+
140
+ erbs.each do |out, erb|
141
+ base = '.'
142
+ main_rb = File.basename main
143
+ task out => [test_dir, erb] do
144
+ File.write out, ERB.new(File.read erb).result(binding)
145
+ end
146
+ end
147
+
148
+ wasm_files.each do |to, from|
149
+ task to => [test_dir, from] do
150
+ File.symlink "../#{from}", to unless File.symlink? to
151
+ end
152
+ end
153
+
154
+ file main => test_dir do
155
+ File.write main, <<~'END'
156
+ require 'rubysketch'
157
+ using RubySketch
158
+
159
+ setup do
160
+ size 640, 480
161
+ gravity 0, 1000
162
+ @grounds = [
163
+ createSprite(0, height - 30, width, 30),
164
+ createSprite(0, 0, 10, height),
165
+ createSprite(width - 10, 0, 10, height)
166
+ ]
167
+ @sprites = []
168
+ end
169
+
170
+ draw do
171
+ background 20
172
+ fill 100
173
+ sprite @grounds
174
+ fill 0, 200, 100
175
+ sprite @sprites
176
+ fill 255
177
+ textSize 24
178
+ textAlign RIGHT
179
+ text "#{frameRate.round} FPS", width - 100, 30
180
+ end
181
+
182
+ mousePressed do
183
+ s = createSprite mouseX, mouseY, 30, 30
184
+ s.dynamic = true
185
+ @sprites << s
186
+ end
187
+ END
188
+ end
189
+
190
+ directory test_dir
191
+ end
@@ -0,0 +1,49 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Reight</title>
6
+ <style>
7
+ body {margin: 0; background: #222; display: flex; justify-content: center; align-items: center; height: 100vh;}
8
+ canvas {background: #000;}
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <canvas id="canvas"></canvas>
13
+
14
+ <script>
15
+ window.addEventListener('error', (e) => {
16
+ console.error('[window error]', e.message, e.error);
17
+ });
18
+ window.addEventListener('unhandledrejection', (e) => {
19
+ console.error('[unhandled rejection]', e.reason);
20
+ });
21
+ </script>
22
+ <script src="<%= base %>/reight.js"></script>
23
+ <script type="module">
24
+ const BASE = '<%= base %>';
25
+ const libRes = await fetch(`${BASE}/reightlib.js`);
26
+ const libBlob = new Blob([await libRes.text()], {type: 'application/javascript'});
27
+ const libUrl = URL.createObjectURL(libBlob);
28
+ const {loadReightLib} = await import(libUrl);
29
+
30
+ const srcRes = await fetch('<%= main_rb %>');
31
+ const srcText = await srcRes.text();
32
+
33
+ const RubyModule = {
34
+ canvas: document.getElementById('canvas'),
35
+ print: (s) => console.log('[ruby]', s),
36
+ printErr: (s) => console.error('[ruby err]', s),
37
+ onAbort: (s) => console.error('[abort]', s),
38
+ locateFile: (path) => `${BASE}/${path}`,
39
+ preRun: [(mod) => {
40
+ mod.FS.writeFile('/main.rb', new TextEncoder().encode(srcText));
41
+ }],
42
+ arguments: ['-e', 'load "/bundle/setup.rb"; load "/main.rb"'],
43
+ };
44
+ globalThis.__ruby_module = RubyModule;
45
+ loadReightLib();
46
+ Module(RubyModule);
47
+ </script>
48
+ </body>
49
+ </html>
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.1.18
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-09 00:00:00.000000000 Z
11
+ date: 2026-05-20 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.12
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.12
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.12
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.12
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.12
47
+ version: 0.3.14
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.12
54
+ version: 0.3.14
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.12
61
+ version: 0.3.14
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.12
68
+ version: 0.3.14
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.3.15
75
+ version: 0.4.1
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.3.15
82
+ version: 0.4.1
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.1.18
89
+ version: 1.2.1
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.1.18
96
+ version: 1.2.1
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.7.19
103
+ version: 0.8.1
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.7.19
110
+ version: 0.8.1
111
111
  description: A Retro Game Engine for Ruby.
112
112
  email: xordog@gmail.com
113
113
  executables:
@@ -117,10 +117,10 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - ".github/PULL_REQUEST_TEMPLATE.md"
119
119
  - ".github/workflows/release-gem.yml"
120
+ - ".github/workflows/release-wasm.yml"
120
121
  - ".github/workflows/tag.yml"
121
122
  - ".github/workflows/test.yml"
122
123
  - ".github/workflows/utils.rb"
123
- - ".github/workflows/wasm.yml"
124
124
  - ".gitignore"
125
125
  - CLAUDE.md
126
126
  - CONTRIBUTING.md
@@ -187,6 +187,7 @@ files:
187
187
  - wasm/Gemfile
188
188
  - wasm/Gemfile.lock
189
189
  - wasm/Rakefile
190
+ - wasm/template/index.html.erb
190
191
  homepage: https://github.com/xord/reight
191
192
  licenses:
192
193
  - MIT