I have two mobs standing a couple of turfs apart. They both have a pixel x/y offset on their turf. I know both the offset and the "real" x/y coordinates, ((turf.x-1) * 32 + mob.pixel_x), and of course the turf/mob location on the map. Now I would like to find out the following in a nice quick fashion:
- If you draw a straight line between the mobs from their exact location, which turfs does this line intersect? Should be simple, but I want it optimized!
- A bit more tricky: For every turf that the line intersects, I want to know where the line crosses a turf border, and returns the coordinates of that position, relative to the turf it's crossing at the moment. Something like:
+-----C-+-------+ | \-B__ | | | \ | | | -A | +-------+-------+ A = The mob B = I want the coordinates of this position, in this case something like (1,28) C = This position too, since the line keeps going...
I have most of it figured out myself, but I would like to discuss the way to do it best. The reason for problem 2 is of course that I would like to use DrawBox() to draw a line between two points. So, any ideas?