Rebirth 0.6

I finished Rebirth 0.6 tonight. This version adds the GameObject class, which is the base class for objects in the game and on the screen, such as characters, items, missiles, and so on.

In addition to adding the new class, I also did some more refactoring, and made a new mixin module, Drawable, which handles the OpenGL transformation voodoo for GameObject and Shape.

The demo for this version looks the same as before in a screenshot, but you can now control the box with the numeric keypad! The keypad's arrow keys (2, 4, 6, and 8) move the box (down, left, right, and up, respectively). Keypad 7 and 9 rotate the box counterclockwise and clockwise. Keypad + (plus) and - (minus) make the box larger or smaller.

It's not the most impressive demo in the world, but it's nice to be far enough along that I can control objects on the screen. At this point, it would be possible to recreate Pong with Rebirth. How exciting! ;-D

Regarding the depth issue I blogged about last time, I decided to go with the lazy way. Not because it's lazy, but because it's consistent with software like Inkscape / SVG and Flash. After thinking about it, I realized that I've been half-subconsciously modelling the graphics system of Rebirth after SVG. Rebirth's GameObjects correspond to SVG's groups, and Shapes correspond to the various SVG shapes.

Inkscape and SVG have also influenced my plans for shape styles. Shapes will have "fill" and "outline" styles, which can (eventually) be solid colors, images/textures, and perhaps gradients (depending on how confident I'm feeling about my OpenGL skills). You'll be able to control how thick the outlines are, of course, and maybe line stippling (dotted/dashed lines).

I do have two small concerns about Chipmunk integration. The first is that Chipmunk has support for circles, but not for ellipses (ovals). Since Shapes and GameObjects can be squished and squashed and sheared, I'll need to be able to approximate all shapes as polygons, with the transformations applied (glUnproject might help with that). The second is that Chipmunk doesn't support hierarchical objects, so I'll need to figure out how I'm going to handle that. Perhaps just make so that all shapes and children of a physics-enabled GameObject form one body.

Anyway. The next version is supposed to be adding the Circle class, but I might do some rearranging and update the plans, since I've noticed Rebirth is missing a central class to hold the game together as a cohesive unit. Long ago, I called that class Game, and it held a clock, event manager, camera, and world filled with sprites. I'll probably come up with a different class name (to avoid confusion with the GameObject class), but the general idea is the same.


Jonathan submitted a comment on #

Hi Jacius,

I’ve used Rubygame in the past, and liked it quite a lot. That was quite a while ago, but I still check your blog from time to time, to see how things are progressing.

Anyway, I’ve recently gotten into a bit of game programming on the IPhone, and through that, became aquianted with the Cocos2D game lib. Have you looked at it? It seems rather similar to some of your rebirth ideas. One of the good parts about it is that there is a Python version, as well as the Iphone version. So it’s possible to do some prototyping in Python. I’d love to be able to do this with a Ruby game lib. It seems Gosu will be adding support for the IPhone as well, and I think there are a lot of developers out there looking at game development on the IPhone.

I guess what I’m asking is will you be targeting the Iphone eventually? I really think you should, because at the moment, it’s one of the most interesting platforms for an independent (or hobby) game developer.

Also, if you haven’t looked at Cocos2D, I think you should (maybe even make a ruby port from the python version? ;)). It’s base game object is the CocosNode, which sort of resembles your Gobs in Rebirth. Each CocosNode has the basic transformations (pos, scale, rotation) possible, and is also capable of scheduling timers. So a timer is not just a “top level thing”, but something that can be used way down in the hierarchy. Most things in Cocos inherit from CocosNode, even entire Scenes and Layers (and Sprites obviously), which is rather nice. And, just like your Gobs, they can be nested, which is a very useful feature.

Cocos2D also has Chipmunk integration and uses Chipmunk vector objects as it’s basic vectors. If nothing else, you should be able to find some useful code in that project, and if you DO decide to create an Iphone version of Rebirth, there is a lot of finished Objective-C code you could use.

Sorry if I’ve totally bored you with this comment, as you’re probably already aware of Cocos2D, but I really wanted to tip you in case you weren’t, because I’d love to have an alternative where I can prototype in Ruby, and then finish it up on the Iphone, using the same game lib. And I think it’s an excellent way to get interest for your project. Cocos2D is the most used open source project for the IPhone, and programming games natively without using it, requires the kind of OpenGL experience you have, and I lack.

(If you’re not familiar with the project already, and decide to give it a look, be sure to check out it’s Actions. Great way to simplify many common tasks/effects in a typical game.)

Have something interesting to add to the discussion? Email your thoughtful comments to