Joining shapes together and tracing their outline
<p>EDIT: Found solution. I've added it after the question.</p>

<p>I'm designing a game for Android and I'm trying to come up with ways to reduce the calculations at the render stage.  I've got a method at the moment which takes all the metal and rubber blocks in the level and stores a texture id into a int[][] grid so that the renderer just reads that instead of calculating every blocks tiled textures every frame. </p>

<p>This works fine but now I'm trying to create a list of corner and straight pieces for the level edges and the laser blocks in the level. The level bounds and laser blocks are drawn using a set of straight laser textures and corner textures.  I'm not sure how best to tackle working out where not to render lasers where blocks overlap with other blocks and with the level edges. The pictures below shows what I mean:</p>

<p><a href="https://dl.dropbox.com/u/48542022/DRAWING.jpg" rel="nofollow">drawing</a> </p>

<p><a href="https://dl.dropbox.com/u/48542022/INGAME.jpg" rel="nofollow">ingame</a></p>

<p>Here you can see the level edge (the L shaped laser path extending beyond the pictures edges) and three/two internal laser blocks (respectively to picture order). As far as I can tell I should create a similar grid to above but with booleans so any square that kills the player on upon touching (highlighted in red) is true and the safe squares are false.</p>

<p>I then first thought of going through all the true (red) cells in the grid and work out what the laser outline would look like using their neighbouring grid cells but I realised this could very difficult so I'm certain now that I use the false squares to find it out. I'm sure I could get a rough solution working by starting at the lower left square of the level bounds and iterate through the grid until I find a false tile (unless the first square is false) and then travel through the grid going right until I reach a true cell to the right and so I would turn left and continue up through the grid until a true is found above to turn left OR a false is found on the right to turn right. I'd repeat this process until I reach my starting false cell. </p>

<p>I came up with this while writing this question out lol. It seems like the easiest way so I guess my question is is this a good way to do it and how would I work out the laser blocks which touch each other but not touch the level bounds as the above method would only trace the outer most laser path.</p>

<p>Thank you for taking the time to read through this. I hope I've explained it well enough and I look forward to any light that can be shed on this subject.</p>
