To put it gracefully, I'm trying to draw a line from my character to the nearest tile in the direction he's facing. I found out that this can be achieved with a voxel traversal algorithm. The one I'm using is in this tutorial: [url="http://www.metanetsoftware.com/technique/tutorialB.html"]http://www.metanetsoftware.com/technique/tutorialB.html[/url] near the bottom of the page.
I've attached the pdf of the actual algorithm as well.
Everything has gone fine and I have it running. Once the calculation has finished, the algorithm leaves you with the x and y coordinates of the tile(or voxel) that the line should stop at.
This is all well and good, but I'm missing the final step. What are the final x/y coordinates for the end point of the line that I want to draw? It must be very obvious if they felt like excluding it in the pdf, but I just can't figure it out.
To clarify some possible confusion, I have the x and y of the tile(aka x*tile size,y*tile size will give me the in game coordinates) but I want the x and y of where the line should stop after it hits the tile.
Thanks for reading