Pathfinding, in games as in real-life, is the art of discovering the best route from point A to point B. Some tower defense games use pathfinding (although many of them only use a pre-planned route), you’ll also see it in a lot of strategy games where you move units around the screen.
If you’ve poked around at pathfinding you’ve probably come across the most common pathfinding algorithm called A* (pronounced A-star). There are A* implementations in just about every language, including Lua (with Corona SDK implementations).
In this short tutorial series we’re going to look at a Lua library called Jumper. It was written by Roland Yonaba and is available on GitHub (free and open source under the MIT License):
If you’re a git pro, clone that — for the rest of us, just use the ZIP button on that page to download the latest copy.
Jumper is more than just an A* implementation, it’s a pathfinding library designed for grid-based games. And while you can use A* with Jumper, it allows you to use an algorithm called Jump Point Search that’s about 10 times faster than A*.
In this course I will not be digging in to how pathfinding search algorithms work. Smarter people than me have already figured them out and Roland has plopped those algorithms into the Jumper library — making use of that library is what we’re going to focus on.
If you have a grid-based game and need objects to move around the screen, Jumper can help you. And if you don’t think you have a grid-based game, I’ll show you how you can (often) stick a grid underneath where it’s “out of sight” but can still be used by Jumper.