title: How to find all grid squares on a line?
body: <p>I'm trying to implement a line-of-sight algorithm on a 2-dimensional grid.  I know how it needs to work conceptually, but I can't think of how to implement it as an algorithm.</p>
  
  <p>The basic idea is pretty simple.  In pseudocode:</p>
  
  <pre><code>function LineOfSight(point1, point2): boolean
    squares = GetListOfSquaresOnLine(point1, point2)
    for each square in squares
      if square.IsOpaque then return false
    return true
  </code></pre>
  
  <p><code>GetListOfSquaresOnLine</code> would (conceptually) draw a straight line from the center of the grid square at point1 to the center of the grid square at point2, and return a list of all squares that this line passes through.  But that's the part I have no idea how to implement.  Anyone know how to do this?  Delphi or C examples preferred, but not required.</p>