The picture actually looks like it's using Bresenham's algorithm. Notice how it favors one axis (Y) over the other (X)? Even though the actual line covers some tiles by almost half, they aren't in red, while others are barely covered and are in red. It's iterating over Y with error accumulation in X.u
Basically forget the pixel level of it all. Your creating a line between two tiles. Using Bresenhams algorithm over the tiles is the same as using it over pixels.
Now, as others have said, if your really just wanting 'the number of solid tiles between two points' and your counting the tiles in red in the photo, then it is just the greater of the absolute of the difference in Y or X. (As defined by the outer loop in the algorithm.)
ScienthsineMember Since 25 Sep 2008
Offline Last Active May 16 2016 02:13 AM