Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ldd/melonjs-pathfinding
Pathfinding plugin for melonJS
https://github.com/ldd/melonjs-pathfinding
Last synced: 8 days ago
JSON representation
Pathfinding plugin for melonJS
- Host: GitHub
- URL: https://github.com/ldd/melonjs-pathfinding
- Owner: ldd
- License: mit
- Created: 2014-11-22T05:59:45.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-22T06:09:13.000Z (about 10 years ago)
- Last Synced: 2024-10-27T15:51:25.735Z (about 2 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
melonjs-pathfinding
=============MelonJS plugin implementing pathfindings using webworkers
Official repository : https://github.com/ldd/melonjs-pathfinding
Credit: https://github.com/qiao/PathFinding.js/
License: MIT
Usage
=====- Add melonjs-pathfinding folder to your plugins directory and include it on your game page.
- Register it in your game.js:
`me.plugin.register(me.pathFinding, "pathFinding", [arguments]);`
- Call me.pathFinding.postMessage(message) from your entity code.Argument options
================
`me.plugin.register(me.pathFinding, "pathFinding", width, height, type, length, location);`Where:
`width: the width of the grid`
`height: the height of the grid`
`type: type of pathfinding algorithm` (default is jumpPointFinder)
`length: how many grids to hold, 1 per layer` (default is 1)
`location: the path of your plugins` (default is lib/plugins/pathFinding)
message format
===============
to find a path:
`{name: "findPath",
data: {initialPosition:{x:0,y:0}, endPosition: {x:4, y:3}, zLevel: 0, offset: 0}}
`to set some position in the grid as walkable or not:
`{name: "setWalkablePosition",data: [{x: 1, y: 2, z: 3, value: true}]}`to set all nodes in a grid:
`{name: "setWalkableNodes", data: [{nodes: {}}]}`to find out if a position in the grid is walkable:
`{name: "isWalkableAt", data: [{x:4, y: 4, z: 0}]}`to get all grids:
`{name: "getAllGrids"}`extending functionality
==================
Basically, there are two places that you want to change`me.pathFinding.workerListener` to handle the response differently. The current behavior simply prints the response.
`pathObject.prototype.handleAction` to handle the message that is being passed to the worker.