Skip to main content
gamedev.net
🔒 Locked

Coloring sprites at runtime?

Started by simbiant Nov 24, 2003 at 7:05 PM 2 replies 950+ views
Original Post
simbiant
simbiant
I''m working on a game where you can customize your clothing with a multitude of different sprites, like different types of sweaters and what not. But I''d like to make it more customizable by letting the user choose what color he''d like the clothes to be - and I do not want to have to create 10 different colored sprite sheets for one piece of clothing.. So I want the sprite to be greyed out initially and let the program colorize the greyness (give it a colored hue) on-the-fly. What would be the best way to do this? Would it involve masks of some sort? Note I have minimal knowledge on the subject so if this is the case could you shed some light on it? Also, I''m using Visual Basic and basic Windows API functions to blit out my sprites - which may or may not add a degree of difficulty to this whole matter..
JTippetts
JTippetts
If you are using palettized or indexed graphics you could allocate a subset of the palette indices for the different articles of clothing, and use palette entry switching to change the colors. Drawback of this is that anything on the screen drawn using those palette indices (such as another character''s shirt) will change color when you perform the palette switch.

I am unfamiliar with the Windows API, so I am unaware of anything in that regard to help.

In my game, I perform a trick in this manner to render my alphabets, but as I am using OpenGL, it is a very trivial matter to draw each letter or symbol as a quad, and specify vertex colors to give the grey-scale symbol color.

Josh
vertexnormal AT linuxmail DOT org


Check out Golem: Lands of Shadow, an isometrically rendered hack-and-slash inspired equally by Nethack and Diablo.
simbiant
simbiant
someone. anyone.
Gav
Gav
A way to do this is to have a sprite with all the different types of clothing uniquely coloured, eg set the shirt to 128,128,128, the trousers 134,128,128 etc. doesn''t matter what colour they are as long as they''re unique.

At render time, for the shirt, create a surface with the colour that the shirt should be, set your colourkey to be that of the unique shirt colour, eg 128,128,128, and blit the sprite onto this new surface. Voila, your shirt now has the correct colour.

Repeat for each article of clothing.

Then just set the colourkey back to your normal transparent colour and blit as usual.
===========================There are 10 types of people in the world. Those that understand binary and those that don't.( My views in no way reflect the views of my employer. )

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.