I have a tile map in my game and I’m trying to add in a player. The tile map is made in TileD and I’m using slick. Anyways I would like the user of the game to click a tile and have the player move to that tile. Any way I can do this?
Google.
Check out A* (A star)
After trying to code my own A* algorithm and failing to get past the “flood fill” system >:(
Instead of trashing my project I turned to a pre-made A* pathfinding library to do my pathfinding.
Link: https://github.com/xaguzman/pathfinding
The link above if you scroll down also shows you how to use it, I found it rather easy to implement
NOTE: The only problems I found with this library that was if the player was in a certain position, on occasion the player would just walk over a tile that was marked un-walkable (Diagonally)
The library also has a few pathfinding options you can customize, to meet your own pathfinding needs that work with your game:
//or create your own pathfinder options:
GridFinderOptions opt = new GridFinderOptions();
opt.allowDiagonal = false;
opt.dontCrossCorners = true;
// And a few other options :P
Hope this helps ^__^, just download the .jar and add it to your projects build path than follow the tut on their github page.
EDIT: So you can get an idea on how A* pathfinding actually works :point: http://www.policyalmanac.org/games/aStarTutorial.htm
It does seem that most of OP’s questions would be better served by a google search than a forum post. I suppose some people like talking about doing things more than they like doings, though.
That is not meant to be insulting, but seriously OP- a google search goes a long way, and most of the questions you ask here could be solved in a few minutes that way.
And if all you want to do is talk about this stuff instead of actually doing it, that’s fine too- but showing us what you’ve already thought about will make for more interesting discussion than the “give me information” posts you seem to prefer.
Recommended reading: http://www.catb.org/esr/faqs/smart-questions.html
And this is for StackOverflow, but it contains some universally good advice: http://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist
I think this A*Tutorial is really helpfull.
At least it helped me to understand how A* works and i think if you understand it you won’t have any problems implementing it.
More:
[quote]The tile map is made in TileD and I’m using slick.
[/quote]
Thats totally unrelated to your problem of implementing your own pathfinding.