Comments (9)
Hi,
The problem seems to occur with this line:
local path, length = pather:getPath(employee.x, employee.y, map_tile_x, map_tile_y)
The method is prototyped as follows:
pather:getPath(startX,startY,endX,endY)
startX and startY should be the coordinates of the starting point on the tile map, and endX and endY the coordinates for the goal point (still on the tile map). Therefore, are you sure that employee.x and employee.y are valid coordinates on the tile map and not screen pixels/world coordinates ?
Maybe you can try this:
local start_tick = love.timer.getMicroTime()*1000
print(employee.x, employee.y, pather.grid:getNodeAt(employee.x,employee.y)
local path, length = pather:getPath(employee.x, employee.y, map_tile_x, map_tile_y)
local time = (love.timer.getMicroTime()*1000 - start_tick)
from jumper.
Hi and thanks for your support. It prints "128 128 nil"
. The coordinates are right but getNodeAt
always returns nil :-/
from jumper.
Well, that is strange.
I am assuming here that you already have your 2D grid map in a 2-dimensional array.
When you inits a pather, (passing a map and optional search parameters to Jumper), it actually keeps track of the map passed to init Jumper and is accessible through pather.grid.map (actually it isn't internally used, I just set it for future plans).
Anyway, you might want to check if, in the meanwhile, you didn't accidentally set some values to nil.
Just for debugging purposes, try to add these extra lines, run this, so you can workout what's possibly going on :
print('Start Node Tile Coordinates',employee.x, employee.y)
print('Map passed to Jumper',pather.grid.map[employee.y], pather.grid.map[employee.y][employee.x])
print('Internal Matching Node',pather.grid:getNodeAt(employee.x,employee.y))
local path, length = pather:getPath(employee.x, employee.y, map_tile_x, map_tile_y)
Alternatively, so can provide your souce (a *.love file, as it seems you're using Lรถve2D).
from jumper.
Thanks again for helping me, it's very appreciated.
The second print goes crashing because of a nil value. I've joined a *.love file this time hehe. https://dl.dropbox.com/u/199126/test.love The debug code you just told me is located in Game.lua:85
from jumper.
Hi,
Actually I can't run the game, after cloking the continue button, it crashes. See the traceback.
Anyway, I think I saw what the problem was.
The map defined inside office is a 33 (width) x 25 (height) map. Therefore it means that when you are making a pathfinding request, startX, startY and endX, endY shouldn't be values higher than 33 (on X) or 25 (on Y), as they refer to specifics tiles. These values should represent the grid position (not the world position) of your entities.
Looking at your employee class, it appears to x and y attributes stand for their position on the screen. You will have to calculate and keep updated their grid position. In pseudocode, that would be
employee.grid_x = math.floor(employee.x/tileWidth)+1
employee.grid_y = math.floor(employee.y/tileHeight)+1
I am adding +1 here because your map starts indexing at 1,1.
Then you can use these new attributes to make path request:
pather:getPath(employee.grid_x, employee.grid_y, map_tile_x, map_tile_y)
from jumper.
Nevermind that, I had a typo. So far so good, it almost work! I'll keep you updated on my progress :-) Thanks for the help!
from jumper.
Wow it works!!! Thanks a lot, and very good job on the library!
from jumper.
You are welcome!
Good luck on this project, though. I like the gameplay, reminds me GameDev Story that I played like hell on Android.
from jumper.
Haha! GameDev Story is my #1 inspiration for this game. It'll be very different though, more interactive, but still the same vision. I'm glad you like it :-)
from jumper.
Related Issues (20)
- Replace ThetaStar with Lazy ThetAstar
- Add search algorithm : SPFA
- Add search algorithm : Breadth-First Search
- (dis)allow corner crossing in diagonal mode HOT 1
- Remove tunnelling
- Add path:shift()? HOT 3
- Attempt to call method 'getX' (a nil value) HOT 6
- Cannot build due to error in lookuptable.lua HOT 3
- Invalid or unreachable location HOT 3
- regenerate new path HOT 1
- 3D pathfinding with Jumper? HOT 2
- bug with JPS and ORTHOGONAL mode? HOT 4
- direction dependent walkability
- Uses way too much memory. HOT 6
- Syntax error in jumper/core/lookuptable.lua#L1 HOT 2
- Contributor needed? HOT 1
- isOutOfRange not defined - accesses an undeclared global
- node.x and node.y are nil HOT 2
- y and x axis reversed HOT 4
- Couldn't calculate path in a dynamic grid
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jumper.