Rebirth Progress

The super-charged motivation I've had the past few days is starting to dim, but I think I'll be able to get another one or two versions of Rebirth released before I need to take a mini-vacation from it.

Tonight I was working on the Vector class. It was copied over from my old work on Rubygame, but I took the time to create specs for it, one method at a time, testing along the way. Probably a waste of time since the class was already done and I could have just written all the specs in one go, but oh well.

I've decided to insert one more release before the Gob version. This next version will have the Vector class, and the Camera and Shape classes' position, rotation, and scale will be modifiable, and position will use Vector. The code for Camera and Shape's pos/rot/scale attributes were identical, and Gob's would be too once I wrote it, so I decided to refactor it out into a new mixin module (HasTransform) to keep things DRY.

I also implemented some convenience / utility functions, the most interesting of which is need, a clever wrapper for require that takes relative paths. Credit for the cleverness goes to Drew Olson, who made a library with a similar function. I didn't want to add a dependency just for one simple function, so I wrote my own version (which is probably nearly identical; there aren't too many unique ways to write it):

def need( &block )
  require File.expand_path(,
                            File.dirname( eval( "__FILE__",
                                                block.binding ) ))

It's used like this:

need { "vector" }    # requires ./vector.rb

The cleverness is that it uses a block (note the curly braces) to capture the current state at the time the block was created, in the file that called need. This allows you to write the need function in one file, but have it access the __FILE__ variable from the calling file. Crazy!

Anyway, it's 4AM, and I'm rambling. I expect to finish up Rebirth 0.5 tomorrow (er, today).


Have something interesting to say about this post? Email your thoughtful comments to