If someone could offer me their mathmatical expertise I would be very happy.
If your 'A' and you need to get to 'B'. what is the calculation to get a direct line from 'A' to 'B'.Where a and b could be placed anywhere on the "board".
At the moment my line is like this....
. . . B . . . . . . . . * . . . . . . . . * . . . . . . . . * . . . . . . . . . * . . . . . . . . . * . . . . . . . . . A . .
I can't think how to get that line to travel directly from a to b,some kind of mean to use when incrementing x/y is needed.
Use Bresenham's algorithm for the Cartesian points of a straight line. http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
Log in to post a comment.
If someone could offer me their mathmatical
expertise I would be very happy.
If your 'A' and you need to get to 'B'.
what is the calculation to get a direct line
from 'A' to 'B'.Where a and b could be placed
anywhere on the "board".
At the moment my line is like this....
. . . B . . . . .
. . . * . . . . .
. . . * . . . . .
. . . * . . . . .
. . . . * . . . .
. . . . . * . . .
. . . . . . A . .
I can't think how to get that line to travel
directly from a to b,some kind of mean to use
when incrementing x/y is needed.
Use Bresenham's algorithm for the Cartesian points of a straight line. http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm