I’m trying to figure out the proper algorithm to use for displaying what tiles my characters can move to. I’ll use FFT as an example:
The blue area are tiles available and in range of the player for movement. I’ve researched A* which I don’t think will accomplish this, that seems more along the lines of shortest path from point to point. I’ve looked at flood fill which might work or maybe breadth first search?
Most of these algorithms are new to me, my game is build on a 7x7 grid on the X and Z axis. Can someone provide me with some direction and or examples on how to implement this?
A* is in the right direction, but it’s a little to advanced. Basically what you are looking for is a breadth first search.
The set up is pretty simple. You need to construct a graph of your scene. A graph is basically a structure where each node knows all of its neighbours.
The algorithm for a breadth first graph search is straight forward too.
Grab the node the player is on
Grab its neighbours
Continue grabbing neighbours until you reach the movement limit.
If you go into preferences → colors change play-mode tint. I always set my play-mode tint to red or blue, then when I’m testing my game and I change something I know it’s temporary and will revert.
It’s a nice visual reminder, I’d recommend you set it up.
It’s slightly better, but it’s not taking into consideration diagonal tiles. If my character has a movement one of 1, it should only be able to move N,E,S,W. It showing all cardinal directions as well as each diagonal corner.