From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Shadow effects with allegro Date: Fri, 30 Jan 1998 19:40:56 +0000 Organization: None Distribution: world Message-ID: References: <34D1EE7F DOT 451C AT oce DOT nl> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 33 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk A. Jans-Beken writes: >I want my tanks and other objects to have a shadow on the underlying >tile. From the manual and the examples it remains unclear to me how to >do this. I presume that you are using some kind of fixed perspective 2d view, so that you will be able to draw the shape of each shadow at the same time as making the sprite? If so it is very easy to display these: - make two graphics for each sprite: one containing the main image and another containing the shadow (this can just be a black shape, with the zero mask color in all the areas that aren't covered by the shadow). - set up a translucent color mapping table with the create_trans_table() function, and set the global color_map variable to point at it. See the ex24.c program for a sample of how to do this. - in your display engine, after drawing the solid part of each sprite, draw a translucent copy of your shadow shape in the same location, with the draw_trans_sprite() routine, or draw_trans_rle_sprite() if you have stored the images in RLE format. Voila! Nice translucent shadows that will work over the top of any background. Note that the translucent drawing functions have to read from the destination surface, so they will be very slow if you are rendering directly to video memory. This kind of code usually runs much faster in a double-buffering system where you do all the drawing onto a memory bitmap. -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa