Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/partysun/hxpathfinding
Easy to use pathfinding library in haxe language.
https://github.com/partysun/hxpathfinding
Last synced: 13 days ago
JSON representation
Easy to use pathfinding library in haxe language.
- Host: GitHub
- URL: https://github.com/partysun/hxpathfinding
- Owner: Partysun
- License: mit
- Created: 2015-02-08T18:47:38.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-27T09:20:04.000Z (over 9 years ago)
- Last Synced: 2024-05-03T07:51:42.428Z (7 months ago)
- Language: Haxe
- Size: 242 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PathFinding (Haxe Library)
==============
## The 'KISS' path-finding library in haxe. ##*Haxe* is awesome language for game development. And Haxe should has the cool *easy to use* pathfinding lib.
Install
------`haxelib git pathfinding [email protected]:Partysun/hxpathfinding.git`
And then in your project's hxml build file, add
`-lib pathfinding`
Usage
-----------`AStarFinder` is the first algorythm in the library.
GridMap example:
```haxe
var map:GridMap = new GridMap(9, 9);
start_node = map.getNode(2, 1);
goal_node = map.getNode(5, 4);
map.getNode(5, 1).walkable = false;
map.getNode(2, 2).walkable = false;
map.getNode(3, 2).walkable = false;
map.getNode(4, 2).walkable = false;var pathfinder = new Pathfinding(map);
var path = pathfinder.findPath(start_node, goal_node);trace("Path:" + path);
```You can render debug sprite, if you work with Openfl:
```haxe
debug.clear();
debug.draw(map, path);
addChild(debug.display);
```WaypointsMap example:
```haxe
import pathfinding.Pathfinding;
import pathfinding.core.WaypointsMap;
import pathfinding.core.Node;
import pathfinding.core.Path;var map = new WaypointsMap();
// map generation
start = map.addNode(new Node(baseX, baseY));
map.addNode(new Node(baseX + 70, baseY));
map.addNode(new Node(baseX + 150, baseY));
map.addNode(new Node(baseX + 150, baseY + 70));
goal = map.addNode(new Node(baseX + 270, baseY));
map.nodes[0].neighbors.push(map.nodes[1]);
map.nodes[1].neighbors.push(map.nodes[0]);
map.nodes[1].neighbors.push(map.nodes[2]);
map.nodes[2].neighbors.push(map.nodes[1]);
map.nodes[2].neighbors.push(map.nodes[4]);
map.nodes[4].neighbors.push(map.nodes[2]);// find path
var pathfinder = new Pathfinding(map);
var path = pathfinder.findPath(start, goal);trace("Path:");
for (node in path.nodes)
{
trace(node + "");
}
```For more samples, look at sample directory.
TODO
------------ [ ] More useful tools
- [x] Debug graphic mode
- [ ] Add one more algorythm
- [ ] Add flexeble interface for change a heuristic
- [ ] Add benchmark (http://www.movingai.com/benchmarks/)
- [ ] Add Heap or PriorityQueue for the openlist. It's the critical place of lib speedCHANGELOG
-----------v 0.2.1 - 27.02.2015
- Fix backtrace functions. Clear old data
v 0.2.0 - 18.02.2015
- Tools for GridMap. Tools help work with real game world and model of map.
- Debug modev 0.1.0 - 15.02.2015
- Two basic sceanrio: GridMap and WaypointsMap
- AStar algorythm
- Manhattan heuristic
- Openfl sample
- Tests