JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q33116F
  • License GPL-3.0

A* Pathfinder Algorithme for node.js 2d game

Package Exports

  • find2d

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (find2d) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Find2d (Astar)

Install

$ npm install find2d

How to use

var astar = require('find2d');
//Game Area Rectangle
var Rectangle = new Astar.Rectangle(0,0,20,20);
//PointA = Start point;
var PointA = {X:0,Y:0},
//PointB = End point; 
    PointB = {X:19,Y:19};
//Generate Tiles
var t = Astar.Tiles(PointA, PointB, Rectangle);

var AS = new Astar(t[PointA.X][PointA.Y], t[PointB.X][PointB.Y], Rectangle);

console.log(AS.Road);

With Collidable Object Rectangle

var astar = require('find2d');
//Game Area Rectangle
var Rectangle = new Astar.Rectangle(0,0,20,20);
//PointA = Start point;
var PointA = {X:0,Y:0},
//PointB = End point; 
    PointB = {X:19,Y:19};

var Collidable = [];
Collidable.push(new Astar.Rectangle(2,2,1,1));
Collidable.push(new Astar.Rectangle(2,3,1,1));
Collidable.push(new Astar.Rectangle(2,4,1,1));

//Generate Tiles
var t = Astar.Tiles(PointA, PointB, Rectangle, Collidable);

var AS = new Astar(t[PointA.X][PointA.Y], t[PointB.X][PointB.Y], Rectangle);

console.log(AS.Road);

By default search method is Horizontal and Vertical for define diagonal search you can change this value and initialise the Tiles

#default value H/V
var t = Astar.Tiles(PointA, PointB, Rectangle, false);
#Diagonal search road
var t = Astar.Tiles(PointA, PointB, Rectangle, true);