Move field of view updates to Map.update_field_of_view
This commit is contained in:
parent
9bd287dc9f
commit
47014d4e6e
2 changed files with 8 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue