So I figured out my A* pathfinding, and I want to figure out how to move my entity there! Here is a movement code for the player which happens when you press “up”
trans.y = -speed * delta;
sprite = up;
sprite.update(delta);
and when you press down
trans.y = speed * delta;
sprite = down;
sprite.update(delta);
Because I want my player/ another entity to just walk there, not instantly show up there, and these are the codes I use for arrows keys.
And here is my pathfinding which I want the player to move through, nice and smooth like.
public static void PathFind(int startx, int starty, int endx, int endy) {
if (SimpleMap.MAP[endx][endy] == 1) {
AStarPathFinder pathFinder = new AStarPathFinder(mapd, 100, false);
Path path = pathFinder.findPath(null, startx, starty, endx, endy);
int length = path.getLength();
System.out.println("Found path of length: " + length + ".");
for(int i = 0; i < length; i++) {
System.out.println("Move to: " + path.getX(i) + "," + path.getY(i) + ".");
}
} else {
System.out.println("You can not move here!");
}
}