Ok well, I managed to implement Bresenham's line algorithm. Its creating some nice effects too...
http://www.xanather.com/hmm.pngAnd here is the code:
[source lang="csharp"] static byte GetTileReduction(int x0, int y0, int x1, int y1) { int reduction = 0; if (x0 > x1) { int temp1 = x1; int temp2 = y1; x1 = x0; y1 = y0; x0 = temp1; y0 = temp2; } int deltax = x1 - x0; if (deltax == 0) { deltax = 1; } int deltay = y1 - y0; float error = 0; float deltaerror = (deltay / deltax); int y = y0; for (int x = x0; x < x1; x++) { if (Engine.tiles[x, y].type != 0) { reduction += 20; if (reduction > 255) { reduction = 255; } } error += deltaerror; if (error >= 0.5f) { y = y + 1; error = error - 1f; } } return (byte)reduction; }[/source]
The problem is that this occurs when the light source is completely underground...
http://www.xanather.com/hmm2.pngI am lost, it seems as when the "imaginary" line in the algorithm gets steeper the solid tiles found reduce, resulting in the brighter-than-it-should-be colored tile (brighter) along the vertical parts of the lighting... It should be just a smaller sphere (circle).
I hope you understand what I mean, Ive been trying to tackle this for a while now.
I feel like the actual problem is right under my nose xD
Xanather.
EDIT:
The
[source lang="csharp"]if (deltax == 0) { deltax = 1; }[/source]
is temporary obviously...
Edited by Xanather, 24 September 2012 - 06:14 AM.