Forum: Ruby Intro to embedded Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
05f099fb31709ecf7c78036084ab7e1a?d=identicon&s=25 akrasia (Guest)
on 2006-05-10 02:35
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!
4feed660d3728526797edeb4f0467384?d=identicon&s=25 Bill Kelly (Guest)
on 2006-05-10 02:56
(Received via mailing list)
From: "akrasia" <danxmstie@hotmail.com>
>
> 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/...

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


Hope this helps,

Bill
481b8eedcc884289756246e12d1869c1?d=identicon&s=25 Francis Cianfrocca (Guest)
on 2006-05-10 05:26
(Received via mailing list)
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.
0ca6e5c33d7e7ff901d75ff0b13d9e1c?d=identicon&s=25 Sam Roberts (Guest)
on 2006-05-10 07:39
(Received via mailing list)
Quoting danxmstie@hotmail.com, 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
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-05-10 14:42
(Received via mailing list)
On May 10, 2006, at 1:39 AM, Sam Roberts wrote:

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

Blasphemy! Burn him! Burn him! ;)
This topic is locked and can not be replied to.