diff --git a/erynrl/engine.py b/erynrl/engine.py index d7a5846..0255073 100644 --- a/erynrl/engine.py +++ b/erynrl/engine.py @@ -216,11 +216,7 @@ class Engine: def update_field_of_view(self): '''Compute visible area of the map based on the player's position and point of view.''' - # FIXME: Move this to the Map class - self.map.visible[:] = tcod.map.compute_fov( - self.map.tiles['transparent'], - tuple(self.hero.position), - radius=self.hero.sight_radius) + self.map.update_visible_tiles(self.hero.position, self.hero.sight_radius) # Add visible tiles to the explored grid self.map.explored |= self.map.visible diff --git a/erynrl/map/__init__.py b/erynrl/map/__init__.py index a47a75e..550a25b 100644 --- a/erynrl/map/__init__.py +++ b/erynrl/map/__init__.py @@ -33,6 +33,7 @@ class Map: self.down_stairs = generator.down_stairs self.highlighted = np.full(shape, fill_value=False, order='F') + # Map tiles that are currently visible to the player self.visible = np.full(shape, fill_value=False, order='F') # Map tiles that the player has explored @@ -67,6 +68,12 @@ class Map: self.tiles['dark']], default=Shroud) + def update_visible_tiles(self, point: Point, radius: int): + field_of_view = tcod.map.compute_fov(self.tiles['transparent'], tuple(point), radius=radius) + + # The player's computed field of view + self.visible[:] = field_of_view + def random_walkable_position(self) -> Point: '''Return a random walkable point on the map.''' if not self.__walkable_points: