Experimental feature in GraalVM

运行 Optcarrot

运行演示 #

首先 安装 TruffleRuby JVM 独立版本.

您还需要安装 SDL2

  • 在 macOS 上,使用 brew install sdl2
  • 在基于 RedHat 的 Linux 上,使用 sudo yum install SDL2-devel
  • 在基于 Debian 的 Linux 上,使用 sudo apt-get install libsdl2-dev

然后克隆 optcarrot 仓库

git clone https://github.com/eregon/optcarrot.git
cd optcarrot

然后您就可以玩 Lan Master 游戏了。

在 Linux 上

ruby --jvm bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes

在 macOS 上,您需要额外的标志 --vm.XstartOnFirstThread,才能使 GUI 出现

ruby --jvm --vm.XstartOnFirstThread bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes

注意:--audio=none 用于禁用音频,因为在非 60FPS 速度下音频效果不佳。

要玩游戏,请使用键盘上的 17 键(不要使用小键盘)调整屏幕大小,X 键用于确认/向右转,S 键用于向左转,箭头键用于移动,Q 键用于退出。

更多信息请参见这篇 博客文章.

这里 是在 TruffleRuby 和 MRI 上运行演示的演讲的录制视频。

在其他 Ruby 实现上运行 #

您也可以在 MRI 上运行它进行比较。您需要使用以下命令安装 FFI gem:

gem install --user ffi
ruby bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes

您也可以根据需要在 JRuby 上运行它

jruby bin/optcarrot --print-fps --sdl2 --audio=none examples/Lan_Master.nes

从 TruffleRuby 仓库运行基准测试 #

如果您拥有 TruffleRuby 的本地签出,也可以使用 bench/optcarrot 下的 OptCarrot 版本。有关详细信息,请参见 基准测试 文档。

联系我们