Start by installing GraalVM.
Then add GraalVM/bin in PATH
(or use a Ruby manager):
export PATH="/path/to/graalvm/bin:$PATH"
You also need to install SDL2:
brew install sdl2
on macOSsudo yum install SDL2-devel
for RedHat-based Linuxsudo apt-get install libsdl2-dev
for Debian-based LinuxThen clone the optcarrot repository:
git clone https://github.com/eregon/optcarrot.git
cd optcarrot
Then you can play the Lan Master game.
On Linux:
ruby --jvm bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes
On macOS, you need an extra flag, --vm.XstartOnFirstThread
, for the GUI to appear:
ruby --jvm --vm.XstartOnFirstThread bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes
Note: --audio=none
is used since the audio it not nice at non-60FPS speeds.
To play, use keys 1
…7
(not on numpad) to scale the screen, X
for OK/turn right, S
for turn left, arrows to move around, and Q
to quit.
More information can be found in this blog post.
Here is a recording of a talk running the demo on TruffleRuby and MRI.
You can also run it on MRI for comparison. You will need to install the FFI gem with:
gem install --user ffi
ruby bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes
You can also run it on JRuby if desired:
jruby bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes
If you have a local checkout of TruffleRuby, you can also use the version of OptCarrot under bench/optcarrot
.
See the Benchmarking documentation for details.