I had a burst of inspiration this weekend, so I hammered out Rebirth 0.4, which adds the new Camera class.
Much of the code was borrowed from my earlier forays into OpenGL and higher-level game frameworking. One major different is that, since I'm not attempting SDL support (as I was going to when these features were slated for Rubygame 3.0), I can take advantage of OpenGL's transformation code, rather than implementing my own Transform and Matrix3 classes to calculate how objects look from the camera's viewpoint. I might have to borrow them later, to transform mouse clicks into world and object-local coordinates, but gluUnProject seems to do that already, so I'll have to investigate how to use it in ruby-opengl.
One amusing thing I noticed is that I haven't added any support for modifying the position, rotation, or scale of shapes or cameras — there are readers, but no writers. Obviously, that's no good in the long run! I decided to leave it that way for 0.4 to keep the release small, but I'll be adding that in for 0.5, which will also have the game object class (which I think I'll call Gob). Game object is analogous to Rubygame's Sprite class, except that instead of having an image and a rect, it's made up of Shapes; it will also correspond to Chipmunk's Body class.
I do need to implement a proper 2D vector class (I'm just using [x,y] Arrays right now). I'll probably clean up Ftor for it, then later switch it to be based on Chipmunk's vectors, once I add physics.
I also need to add proper color support (I'm using [r,g,b,a] Arrays now). I'll probably extend the Rubygame color classes to have a "to_opengl" method that converts them to the format used by OpenGL. I'll need a general conversion method too, so that I can run any symbol, string, array, or color through the converter and get a valid color back (or else raise an error). I might extend the OpenGL functions that take a color to do that conversion automatically, if I'm feeling particularly peppy. If I do, I'd use a mixin module so that the new methods can just use
super. (Isn't ruby great?)
The demo for 0.4 looks pretty much the same as it did for 0.3, but the camera viewport deliberately doesn't fill the entire image, to demonstrate that you can make cameras that only draw on part of the screen. This would be useful for having two screens side by side, for example with a 2-player racing game.
This version is tagged as release-0.4 on Github.
Next version is Gob (game object), then Circle, then Color/Style, then Line, then World — after that, nothing's planned, so I'll be thinking about what's after that. Probably the Game class, which manages the flow of the entire game, keeps track of objects in the scene, cameras, the view, global event manager, etc. I'm not sure when Chipmunk will come in.