A* pathfinding in slick

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!");
		}
}

you can make an object move from a current location (x,y) to target location (tx,ty) by doing something like this :


   //distance between current and target location
   float dx = tx - x ;
	float dy = ty - y ;
	
		//normalize it
		int len = (int)Math.sqrt(dx * dx + dy * dy);
		if (len!=0) {
		   dx /= len;
		   dy /= len;
		}

		//scale the vector based on our movement speed
		float speed = 2f;
		dx *= speed;
		dy *= speed;

		//move the entity with our new direction vector
		x += dx;
		y += dy;

Did you even read the question? He’s not asking for linear movement, he’s asking for A* pathfinding, completely different from what you posted. Not to mention that he’s not even using vectors like in your example (minus/negative sign doesn’t operate on vector objects).

@OP
I don’t use Slick, but here’s some explanation and example code by kevglass (you’ve probably seen it already, oh well).

@alaslipknot: The variable len should be a float.

Also, pathfinding, while still moving an object from point A to point B, is a bit more complicated than calculating velocity.