Understanding how to move a trail along a path that changes
<p>So my question is pretty simple... but getting it to work like that is another story. So I'll dig right in!</p>

<p>Objective: I'm trying to make a snake like game and I'm having issues with the trail following the path. I've used previous methods that DID work, however, I'm trying to eliminate the "destination" object so the snake has a free move feel instead of a grid feel. </p>

<p>My issue is when I started rewriting my player class, I got rid of a lot of redundant stuff. My final task is to fix how the trail moves. I'm wanting the trail to follow its trail by sliding into position.</p>

<p>The code I have written that works before (Grid-feel):</p>

<pre><code>public void Move(int delta){
 //        double moveSpeed = (delta * .6f) - (oreWeight * ore + armorWeight * armor);

        //Smooth animation for snake movement
        if(IsMoving() &amp;&amp; (X.equals(destX) &amp;&amp; Y.equals(destY)) ){
            for(int i = 1; i &lt; getSize(); i++){
                if(destX.get(i).intValue() != X.get(i-1).intValue()){
                    destX.set(i, X.get(i-1));
                }
                else if(destY.get(i).intValue() != Y.get(i-1).intValue()){
                    destY.set(i, Y.get(i-1));
                }
            }

            if(left){
                destX.set(0, destX.get(0) - GameBoardNew.blockSize);
            }
            else if(right){
                destX.set(0, destX.get(0) + GameBoardNew.blockSize);
            }
            else if(up){
                destY.set(0, destY.get(0) - GameBoardNew.blockSize);
            }
            else if(down){
                destY.set(0, destY.get(0) + GameBoardNew.blockSize);
            }
        }
        else{
            for(int i = 0; i &lt; getSize(); i++){
                if(up || down){
                    if(X.get(i).intValue() != destX.get(i).intValue()){
                        X.set(i, X.get(i) + Integer.signum(destX.get(i) - X.get(i)));
                    }
                    else if(Y.get(i).intValue() != destY.get(i).intValue()){
                        Y.set(i, Y.get(i) + Integer.signum(destY.get(i) - Y.get(i)));
                    }
                }
                if(right || left){
                    if(Y.get(i).intValue() != destY.get(i).intValue()){
                        Y.set(i, Y.get(i) + Integer.signum(destY.get(i) - Y.get(i)));
                    }
                    else if(X.get(i).intValue() != destX.get(i).intValue()){
                        X.set(i, X.get(i) + Integer.signum(destX.get(i) - X.get(i)));
                    }
                }
            }
        }
}
</code></pre>

<p>And now, since I have reworked it, I am adding in a velocity of how fast the player is traveling along with other conditions, along with trying to get rid of the destination part of the formula and using its body as a way to figure that out. However, what I have, works, until the player moves around fast in different directions... then the body just clumps up together. Its essentially the same formula, but still very puzzled.</p>

<pre><code>public void Move(int delta){
 //        float moveSpeed = (playerSpeed - (oreWeight * getSize() + armorWeight * armor)) * delta;
    float moveSpeed = 1f;

    if(IsMoving() &amp;&amp; player.get(0).getX() == playerDest.get(0).getX()){
        for(int i = 1; i &lt; getSize(); i++){
            if(playerDest.get(i).getX() != player.get(i - 1).getX()){
                playerDest.get(i).setX(player.get(i - 1).getX());
            }
            else{
                playerDest.get(i).setY(player.get(i - 1).getY());
            }
        }

        if(left){
            playerDest.get(0).setX(player.get(0).getX() - moveSpeed);
        }
        else if(right){
            playerDest.get(0).setX(player.get(0).getX() + moveSpeed);
        }
        else if(up){
            playerDest.get(0).setY(player.get(0).getY() - moveSpeed);
        }
        else if(down){
            playerDest.get(0).setY(player.get(0).getY() + moveSpeed);
        }
    }

    for(int i = 0; i &lt; getSize(); i++){
        Rectangle location = player.get(i);
        Rectangle inFront = playerDest.get(i);
        int xVel = Integer.signum((int)inFront.getX() - (int)location.getX());
        int yVel = Integer.signum((int)inFront.getY() - (int)location.getY());
        if(up || down){
            if(location.getX() != inFront.getX()){
                if(xVel == 1){
                    location.setX(location.getX() + moveSpeed);
                }
                else if(xVel == -1){
                    location.setX(location.getX() - moveSpeed);
                }
            }
            else if(location.getY() != inFront.getY()){
                if(yVel == 1){
                    location.setY(location.getY() + moveSpeed);
                }
                else if(yVel == -1){
                    location.setY(location.getY() - moveSpeed);
                }
            }
        }
        else if(right || left){
            if(location.getY() != inFront.getY()){
                if(yVel == 1){
                    location.setY(location.getY() + moveSpeed);
                }
                else if(yVel == -1){
                    location.setY(location.getY() - moveSpeed);
                }
            }
            else if(location.getX() != inFront.getX()){
                if(xVel == 1){
                    location.setX(location.getX() + moveSpeed);
                }
                else if(xVel == -1){
                    location.setX(location.getX() - moveSpeed);
                }
            }
        }
    }
}
</code></pre>

<p>If I do need to clarify any information, I will be glad; just ask! </p>

<p>Thank you for taking your time to read this!</p>
