[gameprogrammer] Re: Calculating Line-Of-Sight

  • From: Jake Briggs <jacob_briggs@xxxxxxxxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Wed, 09 Nov 2005 10:42:25 +1300



Olof Bjarnason wrote:

Yes, but how do you know which walls are on the line?


Look here, when you draw a line, you automatically know which points
are on that line. Google "line drawing" or "bresenhams line segment
algorithm".


Yes, yes, keep your hair on, I understand bresenhams algorithm.



When you have such an algorithm from drawing lines on Stephen's grid,
it is easily modified to instead of drawing a "pixel" at location
(x,y), doing the test I mentioned earlier. That's where my x and y
comes from.




So the x,y position is the point at which the line intersects the wall?


No, the x,y position is one of the candidate coordinates on the grid.


Oh, okay, it makes sense now. I didn't realize that the x,y position was refering to one of the cells (that can be either a wall or a floor) in the 40x40 grid. When you said

> One simple idea is "drawing" a straight line from point A to point B, testing all walls thus "painted".

I thought you were refering to the 4 planes that would line the wall cells, not the wall cells themselves. Maybe we should have called the cells "roof cells" or "floor cells" instead of "wall" and "floor" cells.






-- Jacob Briggs Systems Engineer

Core Technology Limited
Level 1, NZX Centre
11 Cable Street
Wellington
Phone +64 4 499-1108

--

Named after its country of origin 'England', English is a little known dialect 
used by up to 1.5 billion non-Americans worldwide. Some interesting but 
obviously incorrect features of the language include:

- queues of people
- wonderful coloUrs
- the useful metal aluminIum
- the exotic herbs (h-urbs), basil (ba-zil) and oregano (o-re-gaa-no)
- specialiSed books called 'dictionaries' that tell you how to spell words 
correctly

Many people using this bizarre gutter speak also subscribe to the pagan belief 
that water freezes at 0 degrees and that distances should be measured in the 
forbidden mathematical system of base-10...



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: