Skeletal Animation -- The PlanI've decided that it would be a good idea for me to rethink my skeletal animation system.
The parts that I have are (Mostly) good, but I'm running into issues as far as how to draw the images.
The method I was previously considering, drawing the whole skeleton onto a surface, then drawing that surface as a sprite, has turned out to be frought with problems.
Given that, I've changed tactics: Instead of simply flipping a sprite to turn the character around, I've added functionality to the animation bones to allow them to invert themselves. This may require some tweaking, but it should work better.
Doing it this way, I don't have to worry about how to align the sprite, which could get messy. I can also save memory by not drawing a whole mess of intermediate images, and I don't have to worry about the size of an intermediate image! ^o^
The bones will draw themselves thusly:
- Draw child bones that are always below the current one (This is recursive)
- Draw the child bones that should be below the current one based on the direct the skeleton is facing
- Compute the angle of the bone and the offset for the image recursively (May optimize this if I have time)
- If the skeleton is facing left, flip the offset (Which is still local to the skeleton
- Add the offset that represents where the skeleton is being drawn
- Rotate the image for the bone by the calculated angle
- If the skeleton is facing left, flip the image
- Get the Rect for the image, and align its center on the offset point
- Blit the adjusted image onto the destination surface (Given as an argument, and also passed to child bones)
- Draw the child bones that should be above the current one, based on which direction the skeleton is facing
- Draw the child bones that are always above the current one
It shouldn't be too much of a problem to get it working. ^_^
I've also been working on other parts alongside the animation system, such as the entity system and object factory, because I don't want to fall behind on other things. :P
And now, back to work! OwO