Wednesday, 22 July 2009

LOS solved

Starting from Teemu's LOS routine I tried to transform it to Kaduria's block-sized output window. For some reason it didn't work. First I noticed artifacts in line drawing and there was a bug (<= should have been < in line length), but fixing that didn't solve the symmetry problem.

Then I discovered that in order to get symmetric result you have to draw lines in symmetric order from corners to center (previously tried to draw them with one sweep from one corner to another). So, you need eight line drawing sequences for each octet.

Using line drawing for LOS causes also the shallow slope problem which means the routine can't reveal everything, but always stops at wall. This can be solved with los fix -routine that scans for walls and other obstacles, checks if they are next to visible tile and pointing towards the player, then reveal them also if they are in darkness.

I believe the result is very fast LOS, because the tiles are visited roughly twice with line drawing and once with los fix. I'm also using an update map for tile drawing to prevent drawing black LOS tiles if there is already one in that place, so it reduces the amount of tiles output almost always when there is something in darkness.

No comments:

Post a Comment