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.

2D All the way! / Sprites, default transparency colors

Author
Message
Darth Randal
21
Years of Service
User Offline
Joined: 19th Jan 2005
Location: ?
Posted: 7th Mar 2005 08:24
i recently started workin 2d games, and i've hit something of a rut. See i was working on putting some bmps and title screens together, and at this one point where I have a bmp and a sprite onscreen, everything i have colored black on the sprite shows as transparent. is there some way to redirect this effect to another color? heres the problem code if anyone cares to check it out.


Thanks

Watch Apocalypse now
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 7th Mar 2005 09:09
turn the last parameter of the set sprite command to 0.
For example

set sprite SpriteNum, Backsave, 0

or before you load the image for the sprite use set image color key to some other colour than black (this command is only for DBP)

Darth Randal
21
Years of Service
User Offline
Joined: 19th Jan 2005
Location: ?
Posted: 8th Mar 2005 03:29
is there any way to set the transparency color in dbc?

Watch Apocalypse now
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 9th Mar 2005 22:51 Edited at: 9th Mar 2005 23:02
No unfortunately, however in a painting package you can set transparency to your image if you save to a png file. Then you should have transparency in your image in DB in the right places - i think, I haven't used DB in ages (I've got DBP).

The other thing I can think of is if you the expansion pack (or versions greater than 1.2 - i think it is), load your image into a memblock (note your screen resolution has to be in 32 bit mode), and scan the values for a certain colour value, and if you find that value then set the transparency for that value to 255. Then make the memblock to an image and you should have your home made set color key command.

Robot
22
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 15th Mar 2005 03:04 Edited at: 15th Mar 2005 03:06
wow pizzaman do you have an example of how to do that mamblock one?

The happenings of tommorow are behind us now
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 15th Mar 2005 10:55
Hi Robot

Just made this for you, only took a minute. Below is the function:



and this is a sample program using it



There is one problem using this, any black parts (rgb(0,0,0)) are still counted as transparent in DBC, unfortunately. The only way around that is to use a colour close to black such as rgb(1,0,0), etc for the black parts.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th Mar 2005 17:14
The best way is to use the magic wand on the background, then invert the selection, then adjust the brightness of the image by a very small amount to make the black move from 000 to 111, or 222, or 333. It is hard to tell the difference.

Robot
22
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 17th Mar 2005 02:59 Edited at: 17th Mar 2005 03:15
Thank you so much pizza man that is a great example

would you be able to change black by adding this in the function?



The happenings of tommorow are behind us now
pizzaman
22
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 17th Mar 2005 11:13 Edited at: 17th Mar 2005 11:18
Hi Robot

I had tried to make the black opaque once before using a code snippet nearly identicle to yours, however it did not work. Just seeing that code snippet you posted got me thinking why it didn't work. I investigated it and now have a colour key command for all DBC users - Horay. In other words you can now have perfect black, rgb(0,0,0) displayed on screen while making another colour transparent.

These are the new altered functions



Set the ChangeBlack to anything other than 0 to make black not transparent. I also included a function to just set black opaque.

Here is the example program updated



Note that I've only tested this in DBP so could you tell me if it works (I think it should). Anyway hope it helps you.

Robot
22
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 17th Mar 2005 15:09
I edited your origional code a bit by having to change write byte to dword otherwise it did not change the picture and added in the opaque black thing
also changed memblock number as it only goes up to 255 in dbc



The happenings of tommorow are behind us now

Login to post a reply

Server time is: 2026-07-14 00:28:19
Your offset time is: 2026-07-14 00:28:19