Rubygame 2.6 has new been released! Hurrah! There are also final release versions of Nice-FFI 0.2 and Ruby-SDL-FFI 0.1. They've all been uploaded to Rubyforge and are now available for
gem install rubygame. (Note: JRuby users will need to install the ffi stub gem to resolve the gem dependencies.)
Starting in Rubygame 2.6, Rubygame is now pure Ruby, with no compiled C code. Instead, it uses Ruby-FFI (or compatible FFI implementations, e.g. on JRuby) to directly access SDL and related libraries. That means:
- It is much easier to install. You can install it directly from RubyGems (
gem install rubygame) on any operating system, and you don't need a C compiler or SDL headers. Installation instructions for many platforms are available on the wiki.
- It is now possible to use Rubygame on JRuby, and possibly on Rubinius.
- Rubygame will be slightly slower than before. But, the hard work is still being done by SDL, so the speed decrease is only minor. The increased portability and ease of future development greatly outweighs the small speed loss.
Despite the major architectural change, Rubygame 2.6 API is meant to be backwards compatible with Rubygame 2.5 and earlier. If you find an API incompatibility, you should report it as a bug.
However, there are a few minor incompatibilities that are already known, and most likely cannot or will not be fixed:
- Surface#flip now needs SDL_gfx to run. Before, it needed only plain SDL, but the code for it was too slow when reimplemented in Ruby.
- Rubygame::VERSIONS[:sdl_gfx] now reports [0,0,0] when SDL_gfx is available, instead of its real version number. SDL_gfx does not currently provide any way to detect its version number at run time. We suggest checking capabilities instead of version number, anyway. Use Surface#respond_to? to make sure that the methods you want are available, or be prepared to rescue from NameError.
The biggest news for Rubygame 2.6 is of course the port to FFI, but there are also some smaller improvements:
- Surface#set_at now behaves correctly when given a color with an alpha value, setting the pixel to the given color (and opacity, if the Surface has an alpha channel). Unfortunately, there is a long-standing bug that Surface.new doesn't create Surfaces with a correct alpha channel. You should use
my_surface = my_surface.to_display_alphaif you need an alpha channel. (The bug has been around so long that fixing it could break backwards compatibility, so it won't be fixed until Rubygame 3.0.)
- Rubygame automatically initializes itself when loaded, and cleans itself up when your app exits. So, you don't need to call Rubygame.init or Rubygame.quit anymore! Besides being more convenient, this also prevents a crash for old or sloppy games that don't call those methods. It is still safe to call them manually, of course.
- Music.load now automatically opens audio when used, so that MP3 files will load correctly. This fixes Bug #29 (thanks for the report, MadVillain).
- A new sample application (image_viewer.rb), and new docs (keyboard_symbols.rdoc and custom_sdl_load_paths.rdoc), plus updated install guides and other docs.
As I mentioned, the easiest way to install Rubygame is with
gem install rubygame. (If you want to use Rubygame on JRuby, you must install the ffi stub gem first.) Gem and source tarballs are also available, and you can get the source from Github too: