The Build Engine: Part 2

I know it has been a while! I was really sick this whole past week, and I had a ton of schoolwork!

Anyway, the Build Engine utilizes two forms of storage for creating maps: an array of sectors and an array of walls.

In the Build Engine, the current sector the players are in have to be tracked after updating their positions. This is achieved by calling the updatesector(int newX, int newY, int* lastKnownSectorID) function in the code. The algorithm written to do this behavior pattern is as specified below:

  1. The algorithm starts by assuming the player hasn’t moved much within the last update and will try and utilize the lastKnownSectorID to see if the player is in the last known sector.

  2. If the algorithm fails to find the player in the last known Sector, it will check the neighboring sectors of the last known Sector by utilizing its portals.

  3. If it fails to find the player in the neighboring sectors, then the algorithm will linearly search all of the sectors.

I think Fabien Sanglard’s website best explains this idea with the following picture