[RESOLVED] Grid Path Finding

Hi!

I checked this tutorial out: Corona SDK: Game Development Path Finding http://mobile.tutsplus.com/tutorials/corona/corona-sdk-game-development-path-finding/

But it gives me an error. Does this tutorial need an update or is there a better way of doing path finding?

What I’m trying to do is this: there is an n by n grid on the screen, and the user drags his finger from one point to the other. Presently what I’m doing is this:

  1. on began, start recording tile positions
  2. on move, check if it’s a new tile, record ir.
  3. on end, highlight path taken

But then this fails when the user lifts his finger off the grid and places it on the farther end of the grid. I was hoping that the app could make a path from the last position to the new position, which would make it smoother somehow.

Any help, suggestion, etc would be awesome.

Regards,

John

PS: here’s the error for the path finding.
[lua]Runtime error
/Users/kazuo/Desktop/mobile/path-finding/main.lua:44: bad argument #1 to ‘getn’ (table expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘getn’
/Users/kazuo/Desktop/mobile/path-finding/main.lua:44: in function ‘CalcMoves’
/Users/kazuo/Desktop/mobile/path-finding/main.lua:207: in function
?: in function <?:229>
2012-11-25 01:46:34.714 Corona Simulator[4493:707] Runtime error
/Users/kazuo/Desktop/mobile/path-finding/main.lua:44: bad argument #1 to ‘getn’ (table expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘getn’
/Users/kazuo/Desktop/mobile/path-finding/main.lua:44: in function ‘CalcMoves’
/Users/kazuo/Desktop/mobile/path-finding/main.lua:207: in function
?: in function <?:229>[/lua] [import]uid: 186198 topic_id: 33293 reply_id: 333293[/import]

No replies still? :frowning:

Regards,

John [import]uid: 186198 topic_id: 33293 reply_id: 132286[/import]

I would suggest you get a library, test it out, play with it, mess with the code and learn from it and then you only have two options:

  1. Make your own from scratch because I doubt there will be a library out there that does exactly what you want, or
  2. You edit a library to do what you want.

I’d say try this one out, I think it’d be possible to edit to do what you want:
http://developer.coronalabs.com/code/pathfinding-demo

There is also another pathfinding library but I have not used this one so I’m unaware how it works exactly:
http://developer.coronalabs.com/forum/2012/08/28/jumper-extremely-fast-2d-pathfinder-grid-based-games

Good luck [import]uid: 77199 topic_id: 33293 reply_id: 132296[/import]

No replies still? :frowning:

Regards,

John [import]uid: 186198 topic_id: 33293 reply_id: 132286[/import]

I would suggest you get a library, test it out, play with it, mess with the code and learn from it and then you only have two options:

  1. Make your own from scratch because I doubt there will be a library out there that does exactly what you want, or
  2. You edit a library to do what you want.

I’d say try this one out, I think it’d be possible to edit to do what you want:
http://developer.coronalabs.com/code/pathfinding-demo

There is also another pathfinding library but I have not used this one so I’m unaware how it works exactly:
http://developer.coronalabs.com/forum/2012/08/28/jumper-extremely-fast-2d-pathfinder-grid-based-games

Good luck [import]uid: 77199 topic_id: 33293 reply_id: 132296[/import]

+1 to hatethinkingofnames.

As to OP - please don’t bump within 24 hours of making a thread when it’s still on the first page of it’s sub forum; bumping after 9 hours on a weekend may make others less likely to help, so it’s better to try and be just a little patient and wait a day or so.

We do mention this here; http://developer.coronalabs.com/forum/2011/05/05/forum-rules-and-guidelines [import]uid: 52491 topic_id: 33293 reply_id: 132514[/import]

+1 to hatethinkingofnames.

As to OP - please don’t bump within 24 hours of making a thread when it’s still on the first page of it’s sub forum; bumping after 9 hours on a weekend may make others less likely to help, so it’s better to try and be just a little patient and wait a day or so.

We do mention this here; http://developer.coronalabs.com/forum/2011/05/05/forum-rules-and-guidelines [import]uid: 52491 topic_id: 33293 reply_id: 132514[/import]