Jumper : 2D Pathfinder with Jump Point Search (v.1.8.1)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Roland_Yonaba »

Kadoba wrote:Have you considered making the grid dimensions boundless instead of static? I think it would make your library a lot more flexible and could probably be done in a few tweaks.
Yeah, I was about to do that since yesterday, since Karai exposed his problem.
Actually, building the grid with indices from 1 to n was the simplest solution, when I was working on the first releases.
Thanks so much Kadoba, for pointing that out.
I shall give you some karma, once that feature is back.

PS: I am unsure about what you meant when saying "boundless", though...
What I was thinking of, yesterday, was to init the grid on the basis of the very indexes in the collision map passed. Something like:

Code: Select all

  local function buildGrid(map,walkable)
   local count_width, count_height = 0,0
    local nodes = {}
    local isWalkable
      for y in pairs(map) do
      nodes[y] = {}
        for x in pairs(map[y]) do
          isWalkable = (map[y][x] == walkable)
          nodes[y][x] = Node(x,y,isWalkable))
          count_width = count_width+1
        end
      count_height  = count_height +1
      end
    return nodes, count_width, count_height
  end
So that the returned grid will have the same exact representation with the collision map. Is that what you were suggesting ?
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Kadoba »

Close. I'm talking about a formless grid. One without a set width or height and doesn't even have to be rectangle shaped. If you want to know what I'm talking about the grid class in my love-struct and ATL libraries are like that.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Roland_Yonaba »

Okay, I think I see your point.
Well, your grid structure is interesting, and inspiring for some of my others future plans.
Actually, with Jumper, it is kind of an obligation for the grid structure to be more or less "bounded", as it must stick to the collision map the user passes to init Jumper.So I'll try to modify the wait the Grid is set, to handle collision tables starting at 0, so that Jumper will perfectly deal with collision layers from AdvTiledLoader. Hopefully, the snippet I posted above will handle this perfectly.

Thanks again.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Roland_Yonaba »

Sorry for making two posts in a row, but that new one is brings major updates, so...

I have made some changes to Jumper.
The library is not at v1.5.0 (think I might be messing around with versionning, sometimes... :huh: ).
From now on, Jumper will handle perfectly collision maps from Tiled/ AdvTiledLoader without any extra effort.
I've also setup an example repository on Github, where i'll be pushing some demos/examples with differents Lua game engines/framework, as requested by some people.

@Kadoba: I didn't know much of AdvTiled before, but on the basis of a nice sample made by Zeliarden (thanks to him), I played around with it yesterday, and I got impressive results. Congrats on making such a great tool.
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Kadoba »

Roland_Yonaba wrote: @Kadoba: I didn't know much of AdvTiled before, but on the basis of a nice sample made by Zeliarden (thanks to him), I played around with it yesterday, and I got impressive results. Congrats on making such a great tool.
You too! And thanks for making it compatible with ATL. :nyu:
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Karai17 »

Thanks for updating Jumper to work better with ATL! I am now having a different issue now (before your update, too), and I am at a complete loss as to what could be happening. Two issues, actually:

1) Generating a path for my player does not seem to be working as intended. I get a crash when I try to move, it claims my endNode is nil, even though I am passing in new X and Y values to it. startNode is the X and Y where I currently stand, endNode is X+/-1 and Y+/-1 (depending on which direction you walk). Sometimes I am lucky enough to move right. If I hold the right key then the next error becomes checkable.

2) My monsters seemingly randomly decide that one of the nodes (often #3?) in their path has a nil value instead of a table with x,y values. I cannot narrow down to any specific case that this happens in, it just happens. I have noted though that the error seems to go away after a monster catches up to the player, and then the player continues to run away after.

If you could take a few moments to poke at my code a bit, I would be eternally grateful. The relevant files therein are entity.lua and screen/gameplay.lua.

https://dl.dropbox.com/u/12958391/KLDerp.love
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Zeliarden »

Yo!
flooring ex, ey fixes the crash problem
printing the x and y shows what happens
hope it helps you fix the problem

Code: Select all

	local ex, ey = math.floor(ex), math.floor(ey)
	print("sx= " .. sx .. "sy= " ..sy .. "ex= " .. ex .. "ey= " .. ey)
btw do you realy need jumper for the player movement? If player only going to move with keys its abit overkill
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Karai17 »

Thanks for the reply! That did in fact stop the crashing. Unfortunately, the player doesn't actually move now. The player seems to indefinitely jutter between the startNode and endNode.

As for using Jumper for the player, I know it is a little overkill but I wanted to simplify entity movement in general so I have all entities using the same code. It shouldn't affect performance, but it will make reading the code easier :P
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Zeliarden »

Think it has something to do with player speed.
I changed it to 300 and then I could move the player (couldnt find where you set the player speed but in Player:moveToward(x, y, speed) it is very smal, like 0,00x)
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: [Lib/Lua] Jumper : 2D Pathfinder with Jump Point Search

Post by Karai17 »

Player speed does seem to be the issue. From what I can read in the code, the speed is tiles-per-second. In that respect, smaller values should be acceptable (1, 2, etc). Values under 5 seem to lock the payer into juttering, whereas 5 and up "warp" the player to the endNode since it moves so quickly.

the drawing of where an entity is seems to be very far from where it actually is... When I move once, the mob's path is updated. If I hold down my movement key (it only fires 8 times a second due to my tick rate), it seems that my mob jumps very quickly, skipping many nodes, instead of being drawn smoothly. When I stand still, the mob moves at a reasonable speed but when I move it warps about.

And the second problem in my previous posts is still active--sometimes a node becomes nil for no apparent reason.

;~;

EDIT: I've updated my file, code is a little cleaner and player/mobs now have speed in their constructor. I've set the monster speed to 1 which seems to be right--1 tile per second. Totally baffled why player isn't working in the same fashion, though.

It also looks like when a mob is moving diagonally, sometimes it like just skip most of its path and move in its diagonal direction until it hits the path again......?????????????????????

https://dl.dropbox.com/u/12958391/KLD.love

EDIT 2: I fixed the player movement bug. I forgot to return a value, heh... But again, the node becoming nil seems to still be an issue.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Post Reply

Who is online

Users browsing this forum: No registered users and 210 guests