I'm working on a snake game and I've been stuck on the movement for the last half hour or so and figure it's time to get some assistance on this. I've gone through several possible solutions, but I keep getting the same result. When a new piece to the snake is added, it draws the new block in the correct spot to start with, but when the update method is run, all the snake parts are drawn in the same place. This is my code:
LinkedList<WormBlock> wormDataCopy = wormData;
getFirst().setPosition(getFirst().getPosition().add(direction));
for(int i = 1; i < wormData.size();i++){
wormData.set(i, wormDataCopy.get(i-1));
}
Any idea what I've done wrong?