Archived

This topic is now archived and is closed to further replies.

re-colour at render time

This topic is 5115 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

I''m currently working on a fairly simple 2d games project (clone of an old game called Medieval Warriors), in which there is multiplay. Each player has a certain number of warriors, which can be one of 4 different types. We have a sprite for each type, and its quite easy to display these. I''m using DirectX8. What I''m wondering, is the best way of re-colouring parts of the sprites for each player. ie. in strategy games, you might be the red team, so part of each of your units turns red to reflect this. The sprites actually have 2 different recolourable sections, which can be re-coloured to 2 colours chosen by the players from a list of 8 or so colour choices when they set up thier team. At the moment I''m doing this by rendering the sprite, then rendering another graphic over the top of it which is the desired colour, but which is completely transparent except for the bit I wish to change. This works fine, but means that every time I place a single character on the screen I have to render 3 different graphics (plus another because you can also change the weapons they have, but that isnt relevant to my question). When rendering my sprites, I set aside a certain colour key, and it is made transparent, so I dont have blocks around the sprites. I''m wondering if theres a way of setting aside 2 more colour keys, and using them in a similar way to render with the players selected colours, and if this IS possible, is it actually better than my current method? Could someone provide me some info, or links to tutorials or whatnot about this? Thanks in advance.

Share this post


Link to post
Share on other sites
Unless you are using several thousands of warriors storing a seperate warrior sprite for each color seems to be the best way.

or else

If you are using a 256 color mode you can always play with the palette.

Share this post


Link to post
Share on other sites
He probably means this.

Blue = warriorblue.bmp
Green = warriorgreen.bmp

meaning you have a different texture for every different color.

If you allow the player to choose the color from a palette of maybe more than 20, then you will need to have a base sprite with the parts you want for color in a unique color.

Then when loading the game, you could generate the sprite based on what color the player chose and modify the unique color from the base sprite and use that instead.

Share this post


Link to post
Share on other sites
quote:
If you allow the player to choose the color from a palette of maybe more than 20, then you will need to have a base sprite with the parts you want for color in a unique color.

Then when loading the game, you could generate the sprite based on what color the player chose and modify the unique color from the base sprite and use that instead.


Yes - thats what I was thinking about - but I dont know how to do so. I assume it would be similar to how I use a certain colour for transparency, but I dont know how to replace a colour instead of doing transparency. Can someone point me in the direction of an appropriate tutorial?


[edited by - kazgoroth on December 13, 2003 11:10:39 PM]

Share this post


Link to post
Share on other sites