First steps: all of it is in a library called RUDL, so do a
require "RUDL"
before you start using any of it. Also make sure to type "RUDL" in upper case, otherwise it won't work.
Eveything is namespaced by using a module. What that means is that there are two ways of accessing the things in RUDL. First, you can refer to any object in RUDL by sticking
RUDL::
in front of it, like RUDL::Surface or RUDL::EventQueue. This is visually ugly. The next solution is conceptually ugly. You can also include RUDL, mixing it's namespace into the current namespace.
include RUDL
will do that. This might clash with other libraries who define the same names to be something else.
When you want to make a 2D program, create a DisplaySurface. This is used for drawing on. Load some images from disk into Surfaces with load_new. Go into a loop, and do "game logic", "blit (paste) the surfaces to the displaysurface" followed by "displaysurface.flip" to show them.
We're working on a good tutorial for RUDL, but for now, try the samples and read their code, and browse the library reference.
The following datatypes are commonly used by RUDL:
When a coordinate, size or such is needed, RUDL works with arrays of two numbers like [10, 42].
When a rectangle is needed, use an array of four numbers, representing x, y from the top left corner of the screen, and width and height: [x, y, width, height]. Ruby's Array class is extended with a lot of methods to enable things like:
rectangle = [5, 10, 30, 30] puts rectangle.y
(which will print 10)
No checks are done on array length when a method receives a coordinate or rectangle, this enables you to pass a rectangle to a method that wants a coordinate. Only the first two elements will be used (pass [3, 4, 6, 7] and the coordinate will be [3, 4])
When a color is needed, always use an array of [red, green, blue], a [red, green, blue, alpha] array or a hexadecimal 32 bit number: 0xFF8040EE.
A palette is an array containing [r, g, b] arrays.