Sign in to follow this  

2D Character Variations without over 9000 Sprite sheets?

This topic is 822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

This topic is 822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this