pathfinding algorithm

142 views
Skip to first unread message

rene matias riveros salinas

unread,
Aug 26, 2013, 10:10:15 PM8/26/13
to mel...@googlegroups.com
Hello every one, after some months of inactivity i take my project to develop a multiplayer online game again, I see that is there a lot of updates on melon js so I think this is the moment to continue. Ok, so my question is the next, I'm using the qiao pathfinder lib that is really easy to use, but i don't figure out how to use it with melon js. Pathfinder logic is in the server side(node js) i want that when I click a tile on the user side get the tile number(like a grid) and if the type(solid, slope, etc.) I try for a while and read documentation but i don't found yet how to do this task.

melonJS

unread,
Aug 26, 2013, 10:31:59 PM8/26/13
to mel...@googlegroups.com
swmuron actually wrote a plugin for melonJS :

it's based on the A* algorithm (as described in his page), and I guess you can then use it, make it better, or just use it as reference to create your own plugin based on a different algorithm :P

rene matias riveros salinas

unread,
Aug 26, 2013, 11:49:13 PM8/26/13
to mel...@googlegroups.com
Hi thanks for the response, I gonna take a look at the plugin. I have another doubt, last year I get run a example of mana game with node js + socket io to send the locations on the map, with the version 9.2 of melon js it works really well without problem, but know i updated it with the new methods(renderable, etc) and the problem is that when I receive a location it animates the player, but when I receive a set of locations (2 or more) the animation get stuck on the first frame, like it restart the animation to the first frame every time that a location is received instead of finish the animation and start again with other animation cycle. Any clue that what could be the problem?

Rolf Veinø Sørensen

unread,
Aug 27, 2013, 1:49:32 AM8/27/13
to mel...@googlegroups.com
I also created a different example with the help of Jay Oster
Forum topic

It resultet in a simple example you can download at my google drive

Hope this can be of some help for you.

Best regards
Rolf

rene matias riveros salinas

unread,
Aug 27, 2013, 6:58:09 PM8/27/13
to mel...@googlegroups.com
Oh really thanks Rolf, it's a really nice example, that can help me a lot, the idea of the pathfinding is generate it on server side to disable a coordinate injections on the game, but with this I can manage the player moving after get the array of coordinates calculation on the server. Another question if the A* pathfinding can generate diagonal paths?

Rolf Veinø Sørensen

unread,
Aug 28, 2013, 1:04:46 AM8/28/13
to mel...@googlegroups.com
I have included multiple pathfinding algorytms in the example . Take a look at the pathfinding.js


   /*

// alternate heuristics, depending on your game:

// diagonals allowed but no sqeezing through cracks:
var distanceFunction = DiagonalDistance;
var findNeighbours = DiagonalNeighbours;

// diagonals and squeezing through cracks allowed:
var distanceFunction = DiagonalDistance;
var findNeighbours = DiagonalNeighboursFree;

// euclidean but no squeezing through cracks:
var distanceFunction = EuclideanDistance;
var findNeighbours = DiagonalNeighbours;

// euclidean and squeezing through cracks allowed:
var distanceFunction = EuclideanDistance;
var findNeighbours = DiagonalNeighboursFree;

*/
If you plan to use diagonal paths i recommend that you use tiled map with a blank collision layer and create a another layer with the collisions name fx. CollisionPathfinding and remap my function to use that layer it will remove alot of pains with collisionbox on the player.
Reply all
Reply to author
Forward
0 new messages