Rubygame 3: Day 15

Some progress formalizing the sprite system design today.

Thoughts and/or decisions (or tentative decisions) runing through my head:

  1. BB (bounding box; similar to the current Rect) will not be a valid collision shape for this release. It's not a full Shape in Chipmunk, and it would require a significant amount of effort to make it such, and with little gain. I hope to add it for some future release, but for now sprites will simply have to make do with the slightly less efficient Poly shapes (which are still faster than Rubygame's Ruby-implemented Rects).
  2. Sprites will not support resizing for this release, I think. Changing the sprite's Shape on the fly could lead to complications with Chipmunk. But... well... hrmm. Okay, so this one isn't really cleared out of the way yet. I might change my mind on it.
  3. There will be two classes, Sprite and the still tentatively-named Sprite Body (which I formerly called Cluster). Sprites have an image and a Chipmunk Shape, but don't bounce around the scene (they can still act as solid obstacles, though). Sprite Bodies take one or more Sprite in a parent-child relationship, and provide a Chipmunk Body that bounces around. This is basically what I described before with Clusters; I'm repeating it again to say that I'm pretty sure that this is the design I'll be using for the release.
  4. Sprites can be used without a Sprite Body. But because of a Chipmunk limitation (Every Shape must be child to a Body), we have to do a little bit of sneakiness behind the scenes, creating a (possibly temporary) Chipmunk Body to hold the Sprite's Shape. But that Body won't be added to the Chipmunk Space, so it won't bounce around.
  5. Sprites will default to generating their shape as a Poly rectangle based on the dimensions of its image. If a different Shape is provided, obviously the provided one will be used instead, and there is no need to generate one.
  6. There will be (I think) a convenient way of creating a Sprite Body with a single Sprite as a child, setting up the proper relationships. So basically, it would be a "make me a bouncy sprite using this image" sort of thing.
  7. I'm thinking right now that Sprite and Sprite Body probably will not be intended for subclassing. Instead, the kosher way to use them would be to make your own class with Sprite and/or Sprite Body instance attributes. This is still up in the air.

There are probably more thoughts in my head, but it's rather late and I can't think of them clearly, so I'll leave off for now.


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