Well, you might want to take a look at my ImageManager, Tileset and Tile classes from Operation Lambda, though in my game I didn't pack sprites for different poses or orientations into single files. The only time I load multiple tiles from a single png is when loading animation frames. None-the-less, some of it could be helpful.
ImageManager,
Tileset,
Tile, my main
tileset metadata file.
Here's an example usage, the main draw method in my GameplayMap class:
def draw
@background_image.draw(0,0,ZOrder::Stars)
self.each_with_coords do |obj,x,y|
xpos = x * Sizes::TileWidth
ypos = y * Sizes::TileHeight
@floor_image.draw(xpos,ypos,ZOrder::Floor) unless (obj.noun == 'Space')
ImageManager.tile(obj.key).frame(obj.frame_fraction,true).draw(xpos,ypos,ZOrder::Things)
obj.draw_beams(xpos,ypos)
end
end
Edit: By all means, please ignore all the font-related code in ImageManager, by the way. Though functional, it is hideous and not a starting point for your own work. I need to change it. The actual image-related code is pretty good, though. At least, it's served me very well.
I should also note (since this hasn't made it into source comments yet) that in the context of Operation Lambda, a 'Tileset' is a complete set of every tile image that is used by the game. This differs from what is probably the normal use of the term, under which you would have a tileset for each entity, such as a player tileset, a tileset for each enemy, etc. In other words, my Tileset class might be more appropriately called a 'theme' or 'skin'.
Anyway, hope this helps.
Edit again: Spelling.