Path finding gdx-bridge

A bridge for the pathfinding for automatic integration with libgdx tiled maps

License

License

GroupId

GroupId

com.github.xaguzman
ArtifactId

ArtifactId

pathfinding-gdx-bridge
Last Version

Last Version

0.2.6
Release Date

Release Date

Type

Type

jar
Description

Description

Path finding gdx-bridge
A bridge for the pathfinding for automatic integration with libgdx tiled maps
Project URL

Project URL

https://github.com/xaguzman/pathfinding/tree/master/gdx-bridge
Source Code Management

Source Code Management

http://github.com/xaguzman/pathfinding

Download pathfinding-gdx-bridge

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.xaguzman/pathfinding-gdx-bridge/ -->
<dependency>
    <groupId>com.github.xaguzman</groupId>
    <artifactId>pathfinding-gdx-bridge</artifactId>
    <version>0.2.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.xaguzman/pathfinding-gdx-bridge/
implementation 'com.github.xaguzman:pathfinding-gdx-bridge:0.2.6'
// https://jarcasting.com/artifacts/com.github.xaguzman/pathfinding-gdx-bridge/
implementation ("com.github.xaguzman:pathfinding-gdx-bridge:0.2.6")
'com.github.xaguzman:pathfinding-gdx-bridge:jar:0.2.6'
<dependency org="com.github.xaguzman" name="pathfinding-gdx-bridge" rev="0.2.6">
  <artifact name="pathfinding-gdx-bridge" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.xaguzman', module='pathfinding-gdx-bridge', version='0.2.6')
)
libraryDependencies += "com.github.xaguzman" % "pathfinding-gdx-bridge" % "0.2.6"
[com.github.xaguzman/pathfinding-gdx-bridge "0.2.6"]

Dependencies

compile (2)

Group / Artifact Type Version
com.github.xaguzman : pathfinding jar 0.2.6
com.badlogicgames.gdx : gdx jar 1.5.0

test (3)

Group / Artifact Type Version
junit : junit jar 4.10
com.badlogicgames.gdx : gdx-platform jar 1.5.0
com.badlogicgames.gdx : gdx-backend-lwjgl jar 1.5.0

Project Modules

There are no modules declared in this project.

Build Status

pathfinding - APACHE LICENSE 2.0

A java pathfinding library meant to be used for games. It is generic enough to be used in different kind of graphs (though, right now it only has implementation for grid graphs).

It was heavily inspired by this javascript library. Code initially was adapted, then some modifications were made.

This library works with Libgdx's html5 backend, it was even used in my #1GAM january entry.

Current versions:

  • 0.2.6

Installing

The library has been uploaded to sonatype oss repository. If you are using libgdx you can install it via graddle adding this dependency to your core project:

compile "com.github.xaguzman:pathfinding:0.2.6"

There's also the gdx-bridge extension to easily get pathfinding features in your game directly from your tmx maps.

Intro

The library works on a bunch of interfaces:

  • NavigationNode: this basically just represents a node of a graph. contains some getters and setters meant for navigation. Right now, only implementation is GridCell
  • NavigationGrap: a group of navigation nodes. Right now, only implementation is NavigationGrid
  • PathFinder: the implementation for the pathfinding algorithm, current options are:
    • AStarFinder
    • AStarGridFinder
    • JumpPointFinder
    • ThetaStarFinder
    • ThetaStarGridFinder

Finders are fed with so called PathFinderOptions, which determine how the pathfinding will work (allowing diagonal movement, for example).

How to use

You need to create a graph. Be aware the the NavigationGrid class, expects a bidimensional array of GridCell stored as [x][y]

//these should be stored as [x][y]
GridCell[][] cells = new GridCell[5][5];
	
//create your cells with whatever data you need
cells = createCells();
	
//create a navigation grid with the cells you just created
NavigationGrid<GridCell> navGrid = new NavigationGrid(cells);

Now, you need a finder which can work on your graph.

//create a finder either using the default options
AStarGridFinder<GridCell> finder = new AStarGridFinder(GridCell.class);
	
//or create your own pathfinder options:
GridFinderOptions opt = new GridFinderOptions();
opt.allowDiagonal = false;
	
AStarGridFinder<GridCell> finder = new AStarGridFinder(GridCell.class, opt);

Once you have both, a graph and a finder, you can find paths within your graph at any time.

List<GridCell> pathToEnd = finder.findPath(0, 0, 4, 3, navGrid);

That's pretty much all there is to using the library.

Versions

Version
0.2.6
0.2.5
0.2.4