Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » transparent objects

This thread is locked; no one can reply to it. rss feed Print
transparent objects
HardTranceFan
Member #7,317
June 2006
avatar

Within an isometric game, I'd like to create the effect of seeing through a wall or object that a character has moved behind. Where the character stands, the wall or object is completely transparent. The transparency reduces radially away from the character until it becomes completely opaque a given number of pixels away. Would the following way work, or is there a better/faster way around it?

At the start of the game, create a 32bit completely opaque and black (0,0,0,0) bitmap. Update the alpha channel from completely transparent at the centre of the bitmap to completely opaque at the edges. Call this the alpha_bitmap. All loaded game bitmaps are 32bit, with alpha channel set to opaque (0).

During the game, blit the wall section to a temporary bitmap. Call this temp_bitmap. Using an additive blender, draw the alpha_bitmap onto the temp_bitmap . Then using an alpha blender, draw the temp_bitmap to the buffer.

Am I correct in thinking that the step using the additive blender will add only the alpha channel as the rest of the image is black and not affect the visible image?

--
"Shame your mind don't shine like your possessions do" - Faithless (I want more part 1)

ImLeftFooted
Member #3,935
October 2003
avatar

Alternatively you could set the wall as pattern and draw a bunch of expanding circles. Not sure if the CPU effort of circle drawing would outweigh the bunch of blits your method entails.

Go to: