Rubygame 3: Day 23

Did some cleanup work around the event stuff and integer constants, and filled in a couple missing spots in the Sprite and Scene APIs. Still feeling a bit ill today. Also frustrated and disappointed at the moment about difficulties with Rubygame.

I was trying to implement Sprite#draw. It's much more complex than the old Sprite#draw (which was basically just @image.blit(screen, @rect)). Perhaps too complex; more than it needs to be. The idea is that Sprite#draw is provided with a Rendering Context object, which gives information about how/to where the sprite should be drawn. Part of that information is a Transform, which is the basis of how the camera stuff will work.

Ideally, the camera has a transformation, and the sprite has a transformation, and the two can be combined to figure out how the sprite appears on the screen. That all works fine in OpenGL, where the transformation can be applied as a matrix to vertices, and the image is stretched to fit those vertices.

In OpenGL, I don't have to care; I just push the numbers and Voila!, the sprite is drawn with the transformed location/rotation/etc. But in SDL, the image has to be rotozoomed to the correct rotation and size. Which means I have to figure out what the correct rotation and size actually is.

In the past, I thought that perhaps I could cheat and use SDL_gfx's "textured polygon" draw function. But, it doesn't do what I hoped, OpenGL-style texture stretching. Rather, it's just making a shape filled with the given surface as a pattern. (I probably would have been disabused of this misconception earlier, if SDL_gfx had halfway-adequate docs. Bah, I'm grumpy.)

... delirious rambling about the difficulties/impossibility of decomposing a transformation matrix into its component translation, rotation, scale, and shear ...

It would be simpler to figure out if I limited the camera zoom to being uniform, i.e. the same on X and Y. So no squashy or stretchy camera effects, sorry.

Hmm, hmm, hmm. Yes, that might do it. But tomorrow, tomorrow.

... wanders off, talking feverishly to self and bumping into walls ...


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