Now we'll finish the Snake class. The snake consists of pieces. Each turn, let's just add one piece at the head, and delete the last one. This will make the snake appear to slither. You need to add the piece next to the current head (index 0).
Snake (part 17)
You must be signed in to leave a comment
3 January, 06:35
Why do we have to add the last coordinates to the new ones when creating a new head?? I assume that we just need to set new coordinates without adding anything. SnakeSection head = sections.get(0); head = new SnakeSection(head.getX() + dx, head.getY() + dy);