Archived

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

ssibal

Changing sprite color [SDL]

Recommended Posts

Is it possible with SDL to have one sprite (for example a shirt) and be able to dynamically change its color, instead of having to have 5 separate sprites for 5 separate colored shirts?

Share this post


Link to post
Share on other sites
I think it is possible. Look in SDL docs for a function that retrieves a pixel from the screen, and a function that draws a pixel on the screen, then modify then to enable drawing on any surface.

But wouldn''t having different surfaces for different colors work faster?

Share this post


Link to post
Share on other sites
I believe I did this once by creating 8 bit surfaces, and allowing the user to modify the pallet (or say 5 values on the pallet that signified the colors they could change), then convert the 8bit graphic to the truecolor surface dynamicaly.

Share this post


Link to post
Share on other sites