I’ve been “lurking” around these forums for a while and finally have a problem that I can’t find the answer to.
My Problem
------------------
I’m making a sports game in which the player sprites contain no more than about 16 colours (though at the moment they’re all 256 colour PNGs) and are BufferedImages. Eventually the game will have different players and teams so I need to find a way to change the pallette for each player as required.
The solution I was considering
--------------------------------------------
I plan to have an array in in each instance of team with the colors of the Shirts/shorts/socks and another in every instance of player with colours for skin and hair. When a player is drawn the values from the two arrays will be read and used by some class (IndexColourModel???) to replace all instances of colour A(original) with Colour B(from array) and All instances of Colour C(original) with Colour D(from array) e.t.c.
I’ve spent some time looking up solutions on this forum and now think that the IndexColorModel class could hold the key. I looked on the SUN pages and even borrowed a book on “2d Graphics in Java” but I still don’t understand how to use it. Please can someone give me an example (even a very simple one) that will allow me to create/edit a pallette or even better use one created in a program like PaintShop Pro.
This is very important for my “Project” because if it’s not going to work or if it’s too slow(as I suspect it will be), I’ll have to think about whether I should be doing something else, which will be a pity.
Thanks!