lineOfSight

lineOfSight

> Functions

Checks the line of sight between the cell start and the cell end, ignoring the entities in the array entityToIgnore.

Example: if (lineOfSight(getCell(), getCell(enemy)))

The algorithm works as follows:

Parameters
Return
Demonstration

Click on a cell to display all the cells that are in line of sight with it.

Mathematical implementation

lineOfSight uses an algorithm inspired by Bresenham's line drawing algorithm (Wikipedia).