func (c *Creature) FOV(a *area.Area) (cs map[coord.Coord]struct{}) { radius := c.Sight cs = make(map[coord.Coord]struct{}) for x := c.X() - radius; x <= c.X()+radius; x++ { for y := c.Y() - radius; y <= c.Y()+radius; y++ { // Distance between creature x and y coordinates and sight radius. dx := float64(x - c.X()) dy := float64(y - c.Y()) // Distance between creature and sight radius. dist := math.Sqrt(math.Pow(dx, 2) + math.Pow(dy, 2)) // Discriminate coordinates which are outside of the circle. if dist > float64(radius) { continue } // Ignore hero. for _, p := range get_line(c.X(), c.Y(), x, y)[1:] { if !a.ExistsXY(p.X, p.Y) { break } cs[p] = struct{}{} // Terrain that breaks line of sight. if !a.IsXYPathable(p.X, p.Y) { break } } } } return cs }