Phaser3 demo to recreate and showcase Fire Emblem's pathfinding logic
In the Fire Emblem series, the battlefield is arranged as a grid of square spaces, and so a unit's movement is equivalent to the number of adjacent spaces that unit may move in one turn. A unit's ability to move around the map is hindered by the terrain, with certain types of spaces costing more than one movement to cross (such as forests or mountains) or completely disallowing being passed at all (walls and empty spaces).
In my implementation, a unit can spend up to five movement points per turn. My procedurally-generated terrain made with Simplex noise contains spaces with the following movement costs:
For my custom pathfinding algorithm, I adapted the A* search algorithm to traverse over terrain with variable movement costs. A* is an informed search algorithm that finds the shortest path in terms of cost (least distance traveled, shortest time, etc.) given the start and end node of a weighted graph. It does this by maintaining a tree of paths originating at the start node and extending those paths one edge at a time until the goal node is reached.
You can play the demo here. Alternatively, you can run it locally on your computer.
To run the demo locally, you must install node. As of writing this, I'm running the project on v20.11.1
.
git clone https://github.com/stavguo/phaser-emblem.git
npm install
npm run dev
Gustavo D'Mello - [email protected]
Project Link: https://github.com/stavguo/phaser-emblem