2D Character Variations without over 9000 Sprite sheets?

Started by
1 comment, last by Krypt0n 8 years, 7 months ago

Hey everyone,

to be honest, i am not that sure, if i placed my question on the right spot in this Forum, since most threads in this category are about 3D calclation and things like that. So feel free, to tell me, if i should chose another section for this question.

But now, to my Question:

Lets assume we are creating a 2d Plattformer. We want our main character to be able to change his apperance, for example: Haircolor, Weapon, Pants... lets assume we got 3 slots of "Equipment", with 5 options for each. That makes (5*5*5 i guess) 125 possible Combinations.

Do i have to create sprite sheets for every combination? And call them by well.. checking a 125-if-Condition-Loop to pick the right sprite sheet, when changing the apperance in Game?

Guess thats - besides the point of taking at least 9000 years of coding - the least effective way regarding memory...

How is it done properly? Is there something like a easy to implement "on the fly sprite-sheet-creation"?

I would be very grateful for your help!

Advertisement

int index = hair * 5 * 5 + weapon * 5 + pants;

sprite sprite = allSprites[index];

Then order the sprites correctly in the image.

That said, with variations like that, I would suggest drawing the sprite composite. Like drawBaseSprite() then drawSprite(hairSprites[hairIndex], hairPosition) followed by weapon etc.. to draw the items on top of the plain sprite without equipment. This can ofcourse be difficult if you want advanced interactions between sprites, like the hair looking differently if the sprite is carrying a large weapon that reaches his hair or something like that, but usually rather simple rules can be applied like drawing sprites in a particular order. Then the order can be changed depending on the current action, like when idle probably the weapon is drawn before some other equipment to make it appear behind, but when fighting with the weapon drawn it might be drawn last, or just before the gloves or something like that depending on how detailed you want to be, and what direction the sprite is facing.

The exact nature of the ordering is different for every game, depending on the rules and available equipment and actions of the game.

in oldschool days the artist were drawing parts of the character with a different part of the color palette e.g. index 0 to 3 for hat, 4 to 7 for the face.... then you can adjust sprite colors, no matter how those were used, by simply changing the color in the palette.

to change the appearance artist sometimes drew some invisible parts, those were using an color index what was set to transparent, then when you want to make it visible you set those entries to something visible.

that was very limiting, but at the same time it was a very simple and memory+time saving way to realize it. in your example you'd reduce the permutations to just an extra weapon layer, thus 5x, not 125x.

This topic is closed to new replies.

Advertisement