I am making a grid based game which has "line of sight" targeting. Often times a game engine would use Raycast for this but I don't want to use an engine so I am trying to "roll my own" solution.
So basically, given P1,P2
pairs I want to find all those spaces between them (marked X
).
I am having a big of a hard time figuring out how to do this. Somehow I have to find out which sides are closest together and use those as my starting points for "raycast". Then I guess I could take "samples" at cell-size increments and compare those with the indexes of the cells.
Unfortunately, I don't have any code yet ... I was hoping some could help with some pseudocode just to get the algorithm. I think if I could figure out how to get the start and end points for each of the pink lines then I could use that to find the orange squares.