Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Rubystein: Wolfenstein 3D Recreated in Ruby

By Peter Cooper / May 11, 2009

At RailsConf 2009 (of which a summary will be coming soon to Ruby Inside), Hongli Lai and Ninh Bui of Phusion (the guys behind Passenger) gave a presentation called Scaling Rails. As part of this, they wanted to demonstrate that Ruby is powerful enough to run a 3D game at a decent speed so they built Rubystein, a Wolfenstein 3D clone in Ruby, using the Gosu game development library.

Rubystein is not a true clone in the sense that it's exactly the same as Wolfenstein 3D, but the principles are the same. It's heavily tailored to Ninh and Hongli's presentation, however, and features a "pack of Mongrels", various Rubyists, and *** **** as a boss.

As a standalone work, it's impressive. I've not seen such a slick 3D game developed in Ruby before. On my netbook running stock Ruby 1.8.6 it runs slow, but under Ruby Enterprise Edition it's somewhat faster though. To my surprise, however, it also runs perfectly under Ruby 1.9 and it flies there.

Hongli and Ninh are quick to point out that Rubystein is a very, very rough work. The project has no directory structure and is just a giant mass of files. The application itself is reasonably well structured, though, and there's plenty of opportunity to use this code as a base to build your own variations. No instructions are provided, however, so it's not for the timid. To try out Rubystein as it is, just git clone the repository from git://github.com/FooBarWidget/rubystein.git and then run wolf3d.rb.

Note: If you don't have the font Myriad Pro installed, the game will quit when you reach a boss. Either install Myriad Pro or change the font name to something more generic in wolf3d.rb.


  1. rubylicio.us says:

    .. 3D in 2D-game-library accelerated by 3D-hardware :P

  2. Zoran Rilak says:

    ...and it features none other than Sean Connery, of the Zardoz (in)fame, as the main protagonist! Impressive. :)

  3. Vidmantas says:

    Can't try, because gosu fails to install through gems or even source :(

  4. Thijs van der Vossen says:

    Somehow, I don't think recreating a game engine in Ruby that ran fine on a 25 Mhz 386 says much about the performance of Ruby.

  5. Ninh Bui says:

    Hey Pete,

    Thanks for the plug :-) Just wanted to let people know that if you're attending rubyonosx.com that Julian Raschke of Gosu and I will do a talk on game development there with Ruby!

    @rubylicio.us I know right? Doesn't get more contrived than that (apart from using a 3d game to drive a point home at a scaling rails talk perhaps ;-))

  6. Andrew says:

    This is amazing :-)

  7. Gregg Pollack says:

    Just posted the video I made with Ninh of him walking through the game:


  8. Alex says:

    Great work. Run with jruby ?

  9. Brian says:

    I guess I don't see why this is all that impressive. Wolfenstein is nearly two decades old. I sure as hell hope Ruby can run such a game on modern hardware. This feels like demonstrating the towing capacity of a pickup by tossing a cinder block in the back.

  10. Derek Neighbors says:

    This is just too incredible to not share with others. Boss *** is the best spoof ever.

  11. Marlon says:

    It's interesting to try it on Matz Ruby 1.8.7 vs REE....there's a definte speed difference.

  12. Stephen says:

    Next up...Ruake? :P

  13. seydar says:

    Sweet job with the game! However, I must object to having people (ie, *** ****) portrayed derogatorily in this. It's a dick move, and while it's funny for about 3 seconds, I kind of expected better from professionals.

  14. Peter Cooper says:

    seydar: I didn't provide the context on this, but *** **** actually supplied sounds for the game and so, I assume, supports his inclusion in it. I know everyone else in the game was also asked whether they wanted to be included or not.

  15. Peter Cooper says:

    @Thijs van der Vossen: I was thinking that on my journey back from RailsConf. I was trying to work out roughly the multiple in processing power of my machine back then to now, and therefore coming up with a vague multiplier of how much slower Ruby is than x86 ;-P It was at least 100x.

  16. Hongli Lai says:

    seydar: we, the makers of the game, are also portrayed in the game so I'm not sure why you think it's a "dick move" or why it's not "professional". And unlike ***, which only turns into a pony, we actually die in the game.

  17. Stephen says:

    @seydar: begone, troll that thou are!

  18. Ninh Bui says:

    @Thijs van der Vossen: From a performance perspective, definitely, you're right: it just affirms that interpreted language are in general slower than compiled languages. In the case of Carmack, the guy wrote some of the raycasting routines in asm to gain speed seeing as compilers couldn't optimize as aggressively as they can nowadays.

    That's not necessarily the point I want to drive home. Instead, I think one must take into consideration that the code for this game was written in roughly 2500 lines of ruby code in about 80 hours from scratch: from two guys who have never written a game before in their life. I believe that's something that's worth more taking a look at that we believe is the power of Ruby (and Gosu) for enabling one to write games like this in a concise and effective manner.

  19. Ninh Bui says:

    Also, during our talk at Railsconf and as one can also see in the video of the guys from Railsenvy, we assert and confirm that Ruby is indeed relatively slow. Having said that however, one is still able to write silly stuff like games. I believe the headliner on our slides summarizes it best: "Ruby is slow, but not THAT slow".

    (Pete, could you merge this with my previous comment? I'm affraid I hit the submit a bit too soon ;-))

  20. Michael Hartl says:

    I cut my video game teeth on Wolfenstein 3D back in the day ("Mein Leiben!"), and seeing this game in action was one of the highlights of RailsConf for me. Thanks to Hongli Lai and Ninh Bui for making it, and to Gregg Pollack for making that awesome video!

  21. *** **** says:

    Just a quick FYI for y'all. First, I not only gave Ninh and Hongli permission to use my "evil rocker" image in their game, but helped write most of the songs and sound effects for my part of it.

    Why? Because it's damn funny that's why.

    I don't take myself all that seriously, and I'm always interested in helping someone pull off a good laugh. Especially when they do it with code, art, and music.

    I mean c'mon, Sean Connery is running around killing packs of mongrels with a ruby. Right, that's totally meant to be serious. My name comes from a Sean Connery movie named Zardoz. Fucking awesome. This is probably the best tribute yet.

    P.S. Whoever wrote "I like it" up there wasn't me.

  22. Peter Cooper says:

    Whoever it was was posting from a Canadian IP address :P (Brock University, specifically)

  23. Shairon Toledo says:

    it's very funny

    "PHP Power down" - badness... :)

  24. Hubert Łępicki says:

    Woow, this is amazing :D. Good stuff, I split tea all over my t-shirt when I noticed Jed being transformed into pink ponny!

    However, I also can't see this being a proof of Ruby speed, or that it scales well, it's more like a funny joke than that :).

  25. Hubert Łępicki says:

    Sorry, I mean "***" not "Jed" :). Ugh, I wish we had editing comments here.

  26. Jan Wedekind says:

    LOL. That's brilliant. 2600 lines of code. Maybe one should add some nasty snakes as well ;)

  27. Patrick Espake says:

    He is a very simple game, but extramamente heavy to run. I tried to run Ruby 1.8 and no chance. I tried also with Ruby Enterprise Edition.

    Ruby is a very beautiful language, but also very heavy. The performance is not a strong point of Ruby.

Other Posts to Enjoy

Twitter Mentions