In the Introduction post I gave you a link to Jumper on GitHub, but for this tutorial I’m going to use the version I just downloaded — that’s so that if something changes, the demo program will still work. But if you’re going to publish a game using Jumper, it’s probably a good idea to […]
Pathfinding with Jumper
Use a fast algorithm to move objects from point A to point B!
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.
There’s a lot of code included with the Jumper library and if you’re into that kind of thing, diving in and exploring is kind of fun. But you don’t have to understand exactly how it works to use it in your games any more than you need to understand an internal combustion engine in order […]
Sometimes you can create a walkable map ahead of time, and sometimes you need to build the map at game time. That’s what we’ll do in this video. The demo code has some cool features you may want to incorporate into your own games, including a drawer that slides from the top of the screen […]
What happens if you calculate a path for Monster A to the hero and then the hero moves? The monster should react accordingly and find the best path from where it is now to the new location of the hero (target). That’s what this demo will do. But instead of just using one monster, we […]
Pathfinding isn’t needed for every game, but if you have a character moving from one place to another on the screen it may come in handy. For example, take a look at this scene from The Secret of Monkey Island: If you want Guybrush Threepwood to walk to the fireplace you’re going to want at […]
In the sample code and videos I stuck to the “basics” of Jumper to make sure you could fully grok how to use it in your games. But it can do so much more. Watch this video to find out about tunneling and clearance, two things that could be vital for your game to have. […]
In your grid/map you may want to have multiple values to mean walkable. This can often happen when using different tiles to show dirt, stone, wood, etc. This quick video shows how to create a “walkable” function to be used instead of a variable holding a single value. << Back to Jumper Dashboard https://masteringcoronasdk.com/wp-admin/admin-ajax.php
In case I get hit by a bus or something, I also put this course up on Udemy. Since you bought this course here, you can also have free access to the course over there, using this link: Pathfinding Course on Udemy If you liked this course enough to also grab it on Udemy, I’d […]
I finally got tired of manually making walkable maps from Tiled files and created a quick little function that does it for me. Create your walkable are in Tiled and make sure it’s the first layer (the one at the bottom of the Layer list in Tiled). Export your level as Lua and then use […]