[Solved] Java snake game


You could use a Stack or LinkedList for this. Now with every move of the snakes head you add its position (x,y) to the start of the list and remove the last element if there are more elements in the list as the snake length.

And while painting you first paint the background and then the lists elements a the snake.

solved Java snake game