Implement Snake Game
Implement the move
method as required to make a working Snake game.
The game engine will call the move
method every short period to move the snake forward by one cell. The move
method gets the positions of all snake cells (stored in a doubly linked list called LinkedList
, with the head as the snake's head and the tail as the snake's tail), the food position, and the current direction. You need to update the LinkedList
in place, change the snake's body based on the current direction, and finish the move.
You can click the fullscreen button at the top right to see the game and code editor in full screen. After you finish the code, the game will work completely. Click the "Submit" button, then click the "Begin" button in the game to start playing. Enjoy yourself!
Explanation
For beginners, moving the whole snake forward may seem like a complex algorithm, but it is actually simple.