## hex grid border highlighting

*May 9, 2018*

Previously I’ve been doing this by actually highlighting all the possible cells, but it’s looks a lot better if you just highlight the borders. Here’s the results I’ve got after this implementation

Calculating the border cells is a different task which I’ve explained over here. After we have the cells that we can navigate to we need to filter out the border cells. If you look carefully the edges that need highlighting from all the cells in range are the ones that do not have a navigable neighbor. In the image the cell (4,-6,2) and (5,-6,1) are both in range, but they share a border with a navigable cell, so that edge should not be highlighted. The algorithm should be like this:

- Get all the cells in range and the starting cell, and add the starting cell to the cells in range.
- for all the cells loop
- for all the neighboring cells of the current cell loop
- if the cells current neighbor = null or cells in range doesn’t have the neighbor highlight that edge

- for all the neighboring cells of the current cell loop

The actual highlighting is done by placing a quad with a bar texture with the correct rotation and coordinates easily calculated from the current cell we are processing.

Here is a video of the highlighting:

*Tags:
#programming
*