Initializing uneven sized sprites

I’m prototyping my game and using a sprite sheet I downloaded, the image loader that I use cuts the image up into equal parts and loads each one.

The problem I have is the walk animation, for instance, contains sprites that are of uneven width:

Aside from measuring and supplying my image loader with specific dimensions for each image, what’s the best way to split up the sprites and load it?

I like dumb code, so I actually don’t deal with it. In stead, I do this:

a) I make all frames of an animation equal width and height, which probably means adding plenty of blank space in the slimmer frames. Different animations can have different dimensions though
b) my positioning system does not orient from the top-left or bottom-left corner of a sprite/bob but from the center-bottom ‘pixel’. This keeps the thing in the same place no matter that there are differences in animation width; even if you would allow different frame widths. Using the center-bottom also just makes things like floor collision checks slightly easier.

Unfortunately to properly work with a) does require a tiny bit of extra effort; I generate bounding boxes on a per-frame basis by examining the blank space and making the bounding box fit as tight around the opaque area of the frame as possible. But meh, thats the type of code you write once and copy everywhere.

Ok,that was my first thought, I just thought there might be a more elegant solution :stuck_out_tongue:

Perhaps there is, but that reads to me like you are searching for the “best” way of doing it, which doesn’t exist. I settle for a solution that is good enough.

tousche’ good sir ;D

I prefer your unchosen method, by measure them manually. With your sprite above, I just need store 7 (or 6) int in an array. Ofc you need to update code as art one but it could be avoided if you already fix at the sprite.

For uneven sprites I use this little class:
http://www.java-gaming.org/?action=pastebin&id=70

Issues:
[]It means I need to manually find the integer coordinates (i.e. zoomed in using Photoshop)
[
]It’s better for arbitrary sprites than animations (where your names are going to end up char1, char2, char3, char4, etc).
[*]In some cases using uneven sizes will result in a jumpy animation, if the character isn’t lined up frame to frame. If this is the case, it would be much easier to just edit the sprites in Photoshop so that they are (a) lined up frame to frame, and (b) evenly spaced.