Writing games in Ruby?

Hey

I'd been messing around with Python for a few weeks when I came upon
Ruby. Personally I much prefer the Ruby syntax (especially the OO
consistency and not not using indents to define blocks). Unfortunately
however, it seems that the Ruby community lacks a stable, easy-to-use
game-module like PyGame - at least I haven't been able to find one (ok
so I found RUDL, but it hasn't been updated for years and it seems to
be buggy).

I mean, is there any language specific reason why Ruby couldn't be
used for writing games the way Python is (ie. we're not talking 3D
action games, but smaller strategy and arcade games)? Is the Ruby
garbage collector bad/slow, is the interpreter much slower or is
something else wrong? Or is it simply a question of time until someone
writes a multimedia plugin to handle sprites, buffered screens, audio
and the like?

I've wondered about that too. It'd be nifty to have a little collection
of old-school arcade games in Ruby - Tetris, Breakout, Space Invaders,
etc. I just haven't done enough GUI programming in Ruby to know how
hard it would be, though...

Yours,

Tom

···

On Thu, 2004-07-15 at 04:47, Innocence wrote:

Hey

I'd been messing around with Python for a few weeks when I came upon
Ruby. Personally I much prefer the Ruby syntax (especially the OO
consistency and not not using indents to define blocks). Unfortunately
however, it seems that the Ruby community lacks a stable, easy-to-use
game-module like PyGame - at least I haven't been able to find one (ok
so I found RUDL, but it hasn't been updated for years and it seems to
be buggy).

I mean, is there any language specific reason why Ruby couldn't be
used for writing games the way Python is (ie. we're not talking 3D
action games, but smaller strategy and arcade games)? Is the Ruby
garbage collector bad/slow, is the interpreter much slower or is
something else wrong? Or is it simply a question of time until someone
writes a multimedia plugin to handle sprites, buffered screens, audio
and the like?

Innocence wrote:

Hey

Moin!

I'd been messing around with Python for a few weeks when I came upon
Ruby. Personally I much prefer the Ruby syntax (especially the OO
consistency and not not using indents to define blocks). Unfortunately
however, it seems that the Ruby community lacks a stable, easy-to-use
game-module like PyGame - at least I haven't been able to find one (ok
so I found RUDL, but it hasn't been updated for years and it seems to
be buggy).

I've used Ruby/SDL -- it works fairly well, but it has some SDL-specific problems.

A good friend of mine is working on creating Ruby bindings for his C++ game framework (called Ruby/Gosu) and another friend of both of us is currently making sure that portability won't be an issue.

I myself have written a game (a cross between Dr. Mario and Sokoban actually) in Ruby for a Ludum Dare contest (Develop a game matching a pre-selected topic all on your own in 48 hours) a few months ago. Speed wasn't a problem -- in fact SDL was the bottleneck. Ruby/SDL was a bit too low-level for my taste; I would have been able to make good use of more framework -- a menu system and something that takes the burden of managing game objects from me. (And I'm going to make sure that such tasks will be handled by Ruby/Gosu or a framework around it.)

Some links to my Ruby/SDL game in case anybody is interested. (Sorry for the partly bad code, but 48 hours can be very short when you also have to develop game art and content. (And if you're not all that good on those.)):

- Screenshot: http://www.ludumdare.com/user/1011/Infectoban.png
- Complete windows package: (This includes the game itself and some SDL
   DLLs that it needs. You're not all that likely to have that DLLs so
   you probably best pick this one.)
   http://noegnud.sourceforge.net/flgr/Infectoban-dll.zip
- Windows package without DLLs:
   http://noegnud.sourceforge.net/flgr/Infectoban.zip
- Source code: (This is the portable version of the game, it should work
   everywhere, but you will need to have Ruby/SDL available on your
   system. On http://raa.ruby-lang.org/project/ruby-sdl/ you can get
   Ruby/SDL)
   http://noegnud.sourceforge.net/flgr/Infectoban-source.zip

Regards,
Florian Gross

try ruby/sdl.
http://raa.ruby-lang.org/project/ruby-sdl/
Last update: 2004-04-23 16:12:28 GMT

···

il 15 Jul 2004 01:43:19 -0700, winnocence@hotmail.com (Innocence) ha scritto::

Wow, huge interrest in this subject - and I though I was the only one
interresed in using Ruby for writing games :stuck_out_tongue:

Peter Thoman:
I did the first 2 of that list (with RUDL, which I think is superior to PyGame btw

How so? On the paper RUDL is using PyGame as a template and PyGame
seems to feature more functionality. PyGame is also more mature which
I guess is the reason why it has fewer bugs. Sadly though, it seems
that both projects are stalled in their current state. It's a real
shame but understandable considering it's freeware :frowning:

I see that other posters here (Florian Gross and Gabriele Renzi)
recommend using only SDL (ie. without a wrapping like RUDL). Is this
really an option? I mean, there must be a reason that modules like
PyGame and RUDL exist, ie. for making handling easier. What's your
take on this Peter?

Florian Gross:
A good friend of mine is working on creating Ruby bindings for his C++
game framework (called Ruby/Gosu) and another friend of both of us is
currently making sure that portability won't be an issue.

Very interresting indeed! Do you think at some point it'll be a viable
alternative to using SDL/RUDL or is it much too soon to say? As far as
I can see RUDL & PyGame both build on top of the Simple DirectMedia
Layer with supposedly is written in C, but from what I can see on
various forums and from what you're saying ("..it has some
SDL-specific problems..."), SDL isn't exactly the Holy Grail. Still if
it's the best there currently, there isn't much to do about it really
:slight_smile:

Seems to me that the Ruby community would really benefit from having a
superiour toolkit for handling gfx and audio. Whether such a toolkit
builds upon the existing SDL (for compatibility) or on a newer,
optimized C framework is hard to say, but presonally I'd prefer the
latter. While Ruby (or any similar high-level language) will probably
never become the language of choice for commercial game programming,
it could become a viable, friendly option for writing games, opening
the programming world to many novice free-time programmers.

I mean, is there any language specific reason why Ruby couldn't be
used for writing games the way Python is (ie. we're not talking 3D
action games, but smaller strategy and arcade games)? Is the Ruby
garbage collector bad/slow, is the interpreter much slower or is
something else wrong? Or is it simply a question of time until someone
writes a multimedia plugin to handle sprites, buffered screens, audio
and the like?

No, Ruby rules :slight_smile:

I don't think many other languages allow you to change the way the core
engine works, then requiring virtually no changes to the code that uses
it, like I did here:

   http://rvv.rubyforge.org/

where I added history to the fields of planets/ships themselves, while
still treating them as regular numbers (coerce() is the trick, and yes
there are other languages that have that).

Note: Ruby-Wise is a widget lib around Xlib written for various reasons,
but not for targeting games.

On a different track, succesful (3D) games often use a scripting language
to glue all their things together, while using ubersophisticated low-level
code for the rendering. Simply because the scripting language makes gluing
easier :slight_smile: There is absolutely nothing wrong with applying several
programming languages to one software project.

+--- Kero ----------------------- kero@chello@nl ---+

all the meaningless and empty words I spoke |
                     Promises -- The Cranberries |

+--- M38c --- http://httpd.chello.nl/k.vangelder ---+

Lets start it up then. Could easily grab an edge over something like
PyGame (which is slowly falling out of date -- its a very inactive
project)

···

On Thu, 15 Jul 2004 22:51:53 +0900, Tom Copeland <tom@infoether.com> wrote:

On Thu, 2004-07-15 at 04:47, Innocence wrote:
> Hey
>
> I'd been messing around with Python for a few weeks when I came upon
> Ruby. Personally I much prefer the Ruby syntax (especially the OO
> consistency and not not using indents to define blocks). Unfortunately
> however, it seems that the Ruby community lacks a stable, easy-to-use
> game-module like PyGame - at least I haven't been able to find one (ok
> so I found RUDL, but it hasn't been updated for years and it seems to
> be buggy).
>
> I mean, is there any language specific reason why Ruby couldn't be
> used for writing games the way Python is (ie. we're not talking 3D
> action games, but smaller strategy and arcade games)? Is the Ruby
> garbage collector bad/slow, is the interpreter much slower or is
> something else wrong? Or is it simply a question of time until someone
> writes a multimedia plugin to handle sprites, buffered screens, audio
> and the like?

I've wondered about that too. It'd be nifty to have a little collection
of old-school arcade games in Ruby - Tetris, Breakout, Space Invaders,
etc. I just haven't done enough GUI programming in Ruby to know how
hard it would be, though...

Yours,

Tom

--
</michael fivis>

"Tom Copeland" <tom@infoether.com> schrieb im Newsbeitrag
news:1089899508.31624.19.camel@hal...

···

On Thu, 2004-07-15 at 04:47, Innocence wrote:
> Hey
>
> I'd been messing around with Python for a few weeks when I came upon
> Ruby. Personally I much prefer the Ruby syntax (especially the OO
> consistency and not not using indents to define blocks). Unfortunately
> however, it seems that the Ruby community lacks a stable, easy-to-use
> game-module like PyGame - at least I haven't been able to find one (ok
> so I found RUDL, but it hasn't been updated for years and it seems to
> be buggy).
>
> I mean, is there any language specific reason why Ruby couldn't be
> used for writing games the way Python is (ie. we're not talking 3D
> action games, but smaller strategy and arcade games)? Is the Ruby
> garbage collector bad/slow, is the interpreter much slower or is
> something else wrong? Or is it simply a question of time until someone
> writes a multimedia plugin to handle sprites, buffered screens, audio
> and the like?

I've wondered about that too. It'd be nifty to have a little collection
of old-school arcade games in Ruby - Tetris, Breakout, Space Invaders,
etc. I just haven't done enough GUI programming in Ruby to know how
hard it would be, though...

Then just do it with ncurses and cute litte ASCII characters... :-))

    robert

Tom Copeland wrote:

I've wondered about that too. It'd be nifty to have a little collection
of old-school arcade games in Ruby - Tetris, Breakout, Space Invaders,
etc.

I did the first 2 of that list (with RUDL, which I think is superior to PyGame btw.)
Screenshots: RUDL: Screenshots

The Tetris game is included in the RUDL distribution if I remember correctly. It's about 500 lines, but that includes the interface, music, and all the block types specified as arrays. Oh, and support for up to 8 (n, basically, but you'd need a huge keyboard...) players and saving and loading of all the options.
Note that the code is from a long time ago when I just started using Ruby, so it's not really a great example to learn from.

The breakout clone uses OpenGL and has pretty nice graphics and even positional stereo sound effects, but has been half-finished for 1 and a half years now.

I just haven't done enough GUI programming in Ruby to know how
hard it would be, though...

It can't be that hard if I could do it 2 years ago :wink:

Seriously, RUDL is IMHO very usable and has a well-designed and extremely Ruby-like interface, the only thing missing are the games! (and more work on the Linux side it seems, but I don't know much about that)

HTH,
- Peter

Innocence wrote:

A good friend of mine is working on creating Ruby bindings for his C++ game framework (called Ruby/Gosu) and another friend of both of us is currently making sure that portability won't be an issue.

Very interresting indeed! Do you think at some point it'll be a viable
alternative to using SDL/RUDL or is it much too soon to say? As far as
I can see RUDL & PyGame both build on top of the Simple DirectMedia
Layer with supposedly is written in C, but from what I can see on
various forums and from what you're saying ("..it has some
SDL-specific problems..."), SDL isn't exactly the Holy Grail. Still if
it's the best there currently, there isn't much to do about it really
:slight_smile:

Well, the guys working on it and me want to use that library the next time we participate in the Ludum Dare competition so it should better be usable by then. :slight_smile:

SDL works, but it can be quite slow in some cases and in others it doesn't provide you what you need at all. It should be good enough for getting started on game development in Ruby however.

Regards,
Florian Gross

Innocence wrote:

Peter Thoman:
I did the first 2 of that list (with RUDL, which I think is superior to PyGame btw
   

How so? On the paper RUDL is using PyGame as a template and PyGame
seems to feature more functionality.

RUDL is more Rubyesque. I used PyGame before, and RUDL got exactly those things "right" that I thought were less than ideal in PyGame. It's hard to explain - it's just that with RUDL, all the classes work like I would expect them to. I posted to the PyGame mailing list about this a long time (3 years?) ago, but I can't find my message in any of the archives now.
An example of what I mean by "rubyesque": To check for bounding box collisions between two lists of sprites, I just call collide_lists( l1, l2 ), which yields each colliding pair into a supplied block. Is that cool or what?

PyGame is also more mature which I guess is the reason why it has fewer bugs.

That may be true, however I only ever encountered a single bug during all the time I used RUDL. That's just anecdotal evidence, but I believe it shows that RUDL is not too buggy to be useful. And if you do find a bug, you can always report it or even fix it yourself. The only bug I found (it had to do with stereo sound effects - seems like I was the first to ever use them) was fixed 3 days after I reported it.

Sadly though, it seems that both projects are stalled in their current state. It's a real shame but understandable considering it's freeware :frowning:

Well, it's open source, so if there is something you would want to change / fix, go ahead :wink:
Also, the main developer just posted on the forum less than a week ago, so maybe "stalled" is too strong a word...

I see that other posters here (Florian Gross and Gabriele Renzi)
recommend using only SDL (ie. without a wrapping like RUDL). Is this
really an option? I mean, there must be a reason that modules like
PyGame and RUDL exist, ie. for making handling easier. What's your
take on this Peter?

I wouldn't recommend it. If you use Ruby you are probably a fan of the rubyesque coding style - with all it's object-orientedness, block passing and syntactical convenience - which I don't believe a direct conversion of a C library can provide.

Michael Fivis wrote:

Lets start it up then. Could easily grab an edge over something like
PyGame (which is slowly falling out of date -- its a very inactive
project)

The existing RUDL project is quite nice; although the OP complains that it's a bit old and buggy, I think it would make a good starting point if that's what you want to do.

Tim.

···

--
Tim Bates
tim@bates.id.au

I did the first 2 of that list (with RUDL, which I think is superior to
PyGame btw.)
Screenshots: RUDL: Screenshots

The Tetris game is included in the RUDL distribution if I remember
correctly. It's about 500 lines, but that includes the interface, music,
and all the block types specified as arrays. Oh, and support for up to 8
(n, basically, but you'd need a huge keyboard...) players and saving and
loading of all the options.
Note that the code is from a long time ago when I just started using
Ruby, so it's not really a great example to learn from.

I got Rudl 0.7.1 to compile, but regrettably urlaubtris segfaulted when
I gave it a whirl. The same thing happened on about half the samples,
though, so perhaps my setup is not good (Ruby 1.8.1, SDL 1.2.7).

The breakout clone uses OpenGL and has pretty nice graphics and even
positional stereo sound effects, but has been half-finished for 1 and a
half years now.

Nifty, which file is that - is it in the samples/ directory?

Seriously, RUDL is IMHO very usable and has a well-designed and
extremely Ruby-like interface, the only thing missing are the games!
(and more work on the Linux side it seems, but I don't know much about that)

Yup, it looks good, and there's a fair bit of recent activity on the
forums, which is nice!

Yours,

Tom

···

On Thu, 2004-07-15 at 13:53, Peter Thoman wrote:

RUDL does look nice. Any of the RUDL guys here on ruby-talk? There are
some names here:

http://sourceforge.net/project/memberlist.php?group_id=42958

but I don't know any of those fellas...

Yours,

Tom

···

On Thu, 2004-07-15 at 10:20, Tim Bates wrote:

Michael Fivis wrote:
> Lets start it up then. Could easily grab an edge over something like
> PyGame (which is slowly falling out of date -- its a very inactive
> project)

The existing RUDL project is quite nice; although the OP complains that
it's a bit old and buggy, I think it would make a good starting point if
that's what you want to do.

Another note on this discussion from several weeks ago - urlaubtris runs
nicely if one applies this little patch to rudl_video_surface.c:

[tom@hal rudl]$ cvs diff rudl_video_surface.c
Index: rudl_video_surface.c

···

On Thu, 2004-07-15 at 15:18, Tom Copeland wrote:

On Thu, 2004-07-15 at 13:53, Peter Thoman wrote:
> I did the first 2 of that list (with RUDL, which I think is superior to
> PyGame btw.)
> Screenshots: RUDL: Screenshots
>
> The Tetris game is included in the RUDL distribution if I remember
> correctly. It's about 500 lines, but that includes the interface, music,
> and all the block types specified as arrays. Oh, and support for up to 8
> (n, basically, but you'd need a huge keyboard...) players and saving and
> loading of all the options.
> Note that the code is from a long time ago when I just started using
> Ruby, so it's not really a great example to learn from.

I got Rudl 0.7.1 to compile, but regrettably urlaubtris segfaulted when
I gave it a whirl. The same thing happened on about half the samples,
though, so perhaps my setup is not good (Ruby 1.8.1, SDL 1.2.7).

===================================================================
RCS file: /cvsroot/rudl/rudl/rudl_video_surface.c,v
retrieving revision 1.35
diff -r1.35 rudl_video_surface.c
1329a1330,1335

static VALUE surface_method_missing(int argc, VALUE* argv, VALUE self)
{
                              // printf("Whoa, method_missing!");
                              return -1;
}

1459a1466

1526a1534

    rb_define_method(classSurface, "method_missing",

surface_method_missing, -1);
[tom@hal rudl]$

There's some oddness going on there that's beyond me - seems like the
RUDL Ruby classes should inherit method_missing() from Object - but I'm
pretty far out of my depth on this one.

Yours,

tom