Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / It's possible to colour sprites?

Author
Message
Giku_
14
Years of Service
User Offline
Joined: 14th Jan 2012
Location: The World
Posted: 26th Feb 2012 12:11
Hi guys, here is a simple question, it's possible to colour sprites via code? Something like setting the RGB of it?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Feb 2012 12:16
What you can do is make a white sprite, and then use:

set sprite diffuse <sprite> , <colour>

To colour it.

TheComet

Giku_
14
Years of Service
User Offline
Joined: 14th Jan 2012
Location: The World
Posted: 26th Feb 2012 13:53
Thanks a lot!
And what about a command to click a sprite instead of making mousex and mousey?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Feb 2012 14:10
Not sure what you mean by that, can you explain?

TheComet

Giku_
14
Years of Service
User Offline
Joined: 14th Jan 2012
Location: The World
Posted: 26th Feb 2012 14:48
No problem mate i just solved

If someone need this i've posted the code:


This operation creates a clickable area around the sprites.
Deet
16
Years of Service
User Offline
Joined: 15th Mar 2010
Location:
Posted: 26th Feb 2012 19:46
Jumping on this topic, does coloring the sprites via set sprite diffuse affect transparent areas of the sprite as well?
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 26th Feb 2012 19:54
the only possible to way to click the sprite is to make 1x1 pixel hiden sprite following the cursor of the mouse, and you just check the sprite collision along with the mouse click..

if sprite collision(MouseSprite,MyButtonSprite)=1 and MouseClick()=1 then...

more 3d models .x/.obj and more foramts here:
[href]https://www.turbosquid.com/Search/Index.cfm?keyword=gogetax1&x=0&y=0[href]
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 27th Feb 2012 02:57 Edited at: 27th Feb 2012 03:01
If your intention is to recolor only parts of a sprite, while leaving other parts colored as they were (like skin, hair) try this:

Draw the colorable parts in sprite images as shades of pure grey (r = g = b), make the image a memblock and convert rgb values that are equal to just r or g or b. You can even make more complex conversions for other colors.

This method also works for textures. It's not fast but not terribly slow if done correctly. Its best done during a load sequence. Animating this effect every screen update (must be faster) would probably require a shader. Or if the sprite is animated with its own frames, you could apply this effect to each frame.

For people who need a more advanced technique.

Login to post a reply

Server time is: 2026-07-10 21:17:20
Your offset time is: 2026-07-10 21:17:20