Ah, good question, I didn’t explain it clearly. You are right, you still need to track if the unit ‘falls behind’ the structure that is obscuring the image, but I was assuming that this condition was met before going into how to draw only the portion of the outline that is being obscured. Sorry about the confusion.
The ‘template’ I was trying to explain was just a polygon that is in an off-screen portion of memory that is only used to define the shape of the building so that you can overlay the unit sprite with this template so that you can figure out (to the pixel) which portion of the sprite is obscured. Naturally, you woudln’t need to do this operation if the unit was physically in front of the building (you don’t need to know which portion of the unit is obscured). If, however, a ‘overlap’ check passes, then you use your off-screen ‘template’ of the building that the unit is walking behind to determine which pixels of the outline should be drawn (if the template pixel is on in the same location as a unit pixel, draw the outline). In fact, now that i think about it more, you only need to use a separeate image for the unit (like a ghost image) that has the outline drawn, so in this case, any template pixel that is covering an outline pixel should be drawn to the screen.
In this case, you have 2 images per unit, the unit image and the ‘ghost outline’ unit image.
I wish I had the vocabulary to explain this, I’m not sure if there’s a game concept of this ‘template’ (…agh, words escape me for how to explain this…) Ok, how about i do this using more mundane props…
Pretend you have a piece of paper, and you draw on the piece of paper the outline of a shape, such as a triangle. Cut the shape out with scissors…this is what I’m calling the ‘template’.
Now, getting back to the game engine, you have your unit moving around the board, and it moves behind a structure. You also have the ‘template’ of the sturcture which could just be a 1-bit depth image of the actual structure. you place the outline unit image on the template in the same relative postion as the acutal unit image is to the actual structure image. if the an outline pixel is in the same position as the template pixel, draw the outline pixel ontop of the actual structure.
Shouldn’t this work? I’m just basically using an off-screen image to store the pixel locations of the actual structure so that i can get a pixel-perfect intersection of the outline and the structure shape.
-Chris