: To add yet another question about Wolf3d games: Has anyone got a good algoritm for eliminating walls that you couldn't see(wall behind other walls). I have tried having it check the tiles in a line between you and the tile in question and haven't had very much success. It may be because I had some errors in my algorith, but I wanted to see if anyone else had a better idea. Also about those pesky wall sections that you can only see part of, is it easiest just to print ther closer one last or is th
er
What you need is whats called an Extent list.
First order of business is to create a list of all walls you want
to draw in order(front to back).
Next you need an array with 1 bit for every pixel wide your
screen is. So if your screen or view window is 320 you need 320 bits(or bytes
for speed) in your array.
Next go through the list front(closest wall to you) to back (wall
furthest away). For each wall fill in the bits in the array that corespond
to the minimum and maximum x value of the wall. If you set any bits in this
step the wall is visible and must be drawn. When all bits in the array are
filled you can stop looking.
Here is some code that should give you the idea.
NOTE: This code is completly un-tested. It is provided as an example only
and proably contains many typing and other errors.