Hey JGO, I’ve finally finished coding a A* Pathfinding system for my game, took about 8 hours (First time ever doing pathfinding or anything like it) I’m happy with the results.
I’m now at that point where I need to perform moving the player from tile-to-tile.
I have a piece of code that handles moving the player from his location in the game world to a given x/y, I just need help on doing this in iterations as I’m lost at the moment D:
I’ve tried using a for loop and that didn’t go too well lol.
Here’s what I have at the moment:
public static void walkPath(LinkedList<Tile> fastestPath) {
for (int i = 0; i < fastestPath.size(); i++) {
// Square to move to.
Tile tile2MoveTo = fastestPath.get(i);
int x = tile2MoveTo.getX();
int y = tile2MoveTo.getY();
// TODO: Walk the player to the x,y
// Once target tile is reached, move to the next tile
if (playerX == x && playerY == y) {
continue;
}
}
}
Any help/feedback is appreciated, thanks