|Company||Yukihiro “Matz” Matsumoto|
|Influences||Perl, Smalltalk, Eiffel, Ada, and Lisp|
|Updated||May 9, 2014 (2.1.2)|
|Licensing||Ruby License or BSD License|
|Platforms||Linux, Unix, Mac OS X, Windows and others.|
|Official site of Ruby|
What is Ruby?
"Ruby is...a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write." It is a pure object orientated language (in the vein of Smalltalk, rather than Simula), but also supports procedural and functional programming.
Roguelike Specific Details
Ruby is still coming of age in the roguelike field -- there are no roguelike libraries and only a few finished games in the language. That said, Ruby is very powerful, combining an elegant syntax with an incredibly dynamic object system. It's also incredibly fun to code with.
- Gosu, a 2D game development library
- Chingu, a game framework that extends Gosu with higher level features
- Ncurses, cross-platform, true Curses support (built-in Curses support has no colours under Windows and is generally a mess)
Interfacing with C
Ruby MRI, the canonical and most popular Ruby distribution, is implemented in C and can make use of C libraries and extensions relatively easy. This is great for leveraging libraries such as libtcod, as well as for writing performance and/or memory critical parts of your application.
- Extending Ruby - The Pragmatic Programmer's Guide A guide to writing C extensions for Ruby. The overhead of this is minimal, but it does require a modicum of boilerplate.
- RubyInline Is a third party module that allows you to inline C code in pure ruby. The overhead is around 2*.
It is possible to use the built-in curses on linux and other platforms, and interface with the Win32 console via the Win32 API for Windows support. However, this is a relative pain. Instead, install the non-standard ncurses-ruby package!
- Download ncurses-ruby1.8-0.9.1-i386-mswin32.zip from http://ncurses-ruby.berlios.de/
- Copy lib/ncurses.rb and ncurses.so into your code directory (don't copy the lib directory itself!)
- In your script, require 'ncurses'
That's it! You can now use ncurses (see the zdennis's ncurses examples at http://github.com/zdennis/ncurses_examples/tree/master or the C API, which is very similar). At some point an example roguelike using ncurses will be uploaded.
Line of sight
Here is a Bresenham's Line Algorithm implementation in Ruby.
Field of View
A few field of view algorithms have been implemented in Ruby
For certain intensive operations it may be prudent to use a Bitfield. One example is storing which map tiles have been visited by your player (and will be drawn).
Using this library, it is easy to add methods to your Map class for FOV calculation:
Over on RubyQuiz there are several quiz solutions which would be useful to anyone wanting to use Ruby for terminal RL games;
- Sokaban. Full game with examples that use Gosu, Curses, OpenGL and plain old terminal. James's 'unix' entry could be useful for a pure ASCII RL jump off point.
- AD&D Dice Roller. Dennis Ranke's full_parser_roll.rb is very interesting.
- Dungeon Generation.
- Maze Generation