Author Topic: FoV and Pathfinding  (Read 6448 times)

zackhovatter

  • Newcomer
  • Posts: 13
  • Karma: +0/-0
    • View Profile
    • Email
FoV and Pathfinding
« on: July 03, 2010, 11:23:10 PM »
Currently, I have 50 entities (51 counting the player) on the dungeon level. Rebuilding the FoVs every turn for every entity is a bit.. slow. Anyone have any input on how to speed things up? Here's what I'm currently doing:

BuildMap():
Builds the FoV Map around the entity based on it's sight. If it has a sight of 5, it loops through position.x-5, position.y-5 to position.x+5, position.y+5

Create Entity
 - Initiate FoV Map, which is the size of the level
 - BuildMap()

Entity Turn
 - BuildMap()
 - ComputeFoV()
 - check if player pos is in FoV
 - Path to player if he is, rebuild path if he has moved

I'm currently rebuilding the FoV every turn even if the entity hasn't moved just in case the player steps into the FoV. This has really slowed down my game though, so it's a bit unacceptable.


Edit: disregard. got some sleep and realized I only needed to build the map once
« Last Edit: July 04, 2010, 07:30:32 AM by zackhovatter »

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: FoV and Pathfinding
« Reply #1 on: July 04, 2010, 07:29:55 AM »
Why do you need to calculate fov for monsters?
You just need to check if there is los from monster to potential object of interest in range.