Intro to embedded Ruby


#1

Hello all!

I’m relatively new to the world of Ruby, but I feel I’m catching on
quickly to the advantages and conveniences that the language offers.
Mostly, I’ve been using it to develop games.

A recent interest of mine involves using Ruby and C/C++ together to
handle a more complex game. My goal is to have C/C++ handle all of the
graphics via SDL or something similar and have Ruby handle all of the
game logic (input, script handling, and such).

Essentially, I’m looking for a basic, from-the-ground-up introduction to
embedding Ruby in C/C++. I’ve had much experience with C/C++ and
programming overall and I am using Linux for development.

Thanks!


#2

From: “akrasia” removed_email_address@domain.invalid

A recent interest of mine involves using Ruby and C/C++ together to
handle a more complex game. My goal is to have C/C++ handle all of the
graphics via SDL or something similar and have Ruby handle all of the
game logic (input, script handling, and such).

Essentially, I’m looking for a basic, from-the-ground-up introduction to
embedding Ruby in C/C++. I’ve had much experience with C/C++ and
programming overall and I am using Linux for development.

Hi,

Not quite what you asked, but you might want to check out Gosu’s
Ruby bindings: http://www.raschke.de/julian/gosu/

Since Ruby / Gosu is a C++ library providing input handling as well as
graphics, etc., and it has Ruby bindings to make the C++ library also
available from ruby, this may provide you with good embedding
examples.

Here’s a recent post from Florian G. about a game written in Ruby /
Gosu,
running on Win32 / OS X / Linux:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/187832

Screenshot: http://flgr.0x42.net/gdc72h-05/final.jpg

Hope this helps,

Bill


#3

I don’t know anything about game programming so this may not be useful
to
you. I’ve tried embedding both ways (Ruby in C++, C++ in Ruby), and I
think
it’s much better to call native code from Ruby. You could look at the
dlopen
library, which is really rather good but lightly documented and somewhat
frustrating. But you might have better luck writing “extensions” in C++.
Read the file README.EXT in the Ruby distro, and then read the source
code
for some of the standard extensions in the distro. With an extension you
can
basically write Ruby in C++, create your own Ruby classes, etc.


#4

On May 10, 2006, at 1:39 AM, Sam R. wrote:

I’m a huge fan of ruby, I use it whenever I can, but not for
everything.

Blasphemy! Burn him! Burn him! :wink:


#5

Quoting removed_email_address@domain.invalid, on Wed, May 10, 2006 at 09:35:35AM +0900:

Hello all!

I’m relatively new to the world of Ruby, but I feel I’m catching on
quickly to the advantages and conveniences that the language offers.
Mostly, I’ve been using it to develop games.

A recent interest of mine involves using Ruby and C/C++ together to
handle a more complex game. My goal is to have C/C++ handle all of the
graphics via SDL or something similar and have Ruby handle all of the
game logic (input, script handling, and such).

I’m a huge fan of ruby, I use it whenever I can, but not for everything.

You might want to look at lua. It allows multiple independent script
contexts (instead of process-global context like ruby), is pretty fast,
has a rich enough language, though is really poor in library support.
I’d never use it as a stand-alone language, but I’ve been really liking
it as an embedded-into-C/C++ scripting language. Also, its apparently
used for a LOT of game developement.

Cheers,
Sam