• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Changing one color on the fly?

Raoul

Member
Hi,
is there any function in GML which allows to replace one color from the palette used in the game with another one?

I have a background picture, which uses only 4 colors. What I am trying to achieve is to change any of the 4 colors on the fly, like if I had modified the original picture but done in memory only.

Any idea?
 
There is no function to change the colors on a palette. You would have to code it yourself or use an extension.

PixelatedPope's retro palette swapper extension can do what you are looking for.

I think it only works with pixel art though.
 
Last edited:

Focksbot

Member
One way you could do it is to separate your background sprite out four different sprites, one for each of your four colours. Change each one to a mixture of white and transparency, draw them on top of one another, and then colour each one of them with image_blend.

Now you'll be able to change the colour of each sprite independently, and they'll all come together to create your original image.
 

Raoul

Member
Hey guys, thanks to both for your quick answers, this community rocks!

@FlameRooster: I thought so but it was worth asking. Long time ago, (almost 20 years sigh) I used to code in a now dead language which had such function, Div Games Studio was the development environment.
My background is pixel art (a classic arcade remake), but I would refrain from using anyone's else libraries as I love to write everything by myself.

@Focksbot: Your suggestion should work, I will do some paint.net work and test it!
 
Last edited:
Top