CRxTRDude wrote:EDIT:to veetree, how did you use bresenham for that lighting? I'm curious about that...
This is pretty much covered in the article I mentionned in my previous post.
Here it is again, there is a section about lighting.
And on the same topic, Amit Patel provided a
tremendous write up (with demos and various implementations) about 2d visibility.
kikito wrote:
Bresenham is good when you have a grid to "parse cells". I guess you could use bresenham to go pixel-by-pixel, but that would not be very fast.
It is also a "beautiful line drawer". It draws only one-cell lines, even when the line touches several cells. This means that not all the cells touched by the line are actually activated by it (this makes it not ideal for things like line-of-sight or shooting. They appear to "miss cells"). If you want to use it for that, you would have to use a "supercover" version of bresenham (unfortunately bresenham.lua does not have that)
Actually, you are definitely right. I was not aware of this until I tried to get it to work. I wanted to implemented
ThetAstar algorithm, which is based on a clever combination of Astar and LOS, and is supposed to return smooth and better looking paths. Unfortunately, it ran into the issue you mentionned (that is, some unwalkable tiles were also traversed by the cast line). I kind of solved the issue by running the algorithm twice (from the starting point to the endpoint and from the endpoint to the startint point), but I was not pretty much satisfied with that hack, so I ended up ditching it until I find something better.