Creating a shadow under a piece being moved
BlitzPlus Forums/BlitzPlus Programming/Creating a shadow under a piece being moved
| ||
Here's the problem. Click on a piece and move it from one square of a board to another. That part was solved in my last post, but now, while the piece is "lifted" above the board, I want to create a shadowed area below and to right (assuming a light source at upper left) in which the shadowed area has reduced brightness but without changing the colors. Also, when the piece is "dropped" onto its new location, the shadow should gradually disappear under the piece until the piece is on the board, with no shadow. I would have to read the color under the shadowed area for every pixel and change it to the dimmer value, or vice versa. Is there a quick way to do this, rather than trying to find out which pixels are between the piece (assume it's circular) and the border of the shadowed area (another circle, same size as the piece but displaced from the piece center by a fixed number of pixels in X and Y directions (distances may be different in each direction.) Any suggestions, anyone? |
| ||
One thing you could try is to look into alpha blending. Although not native in B+, there are a few code archive entries that will do the trick. This one by Nate the Great is a for sprite alpha blending, and seems to work pretty well: http://www.blitzbasic.com/codearcs/codearcs.php?code=2299 You could just make an animation strip of progressively smaller, all black sprites using CreateImage, then alpha blend them on the background, assuming it is a sprite itself. The only issue you're looking at is speed, as it's usually a slow process. That would be my suggestion though. |
| ||
What Sauer said. Here's another alpha-blending routine for B+ that's been optimized to run fairly fast (64x64 sprite in realtime). Scroll down to the second listing. http://www.blitzbasic.com/codearcs/codearcs.php?code=913 |