Implement Snake Game
To implement a functioning Snake game, you need to follow the requirements and complete the move
method.
The game engine will call the move
method periodically to move the snake forward by one cell. The move
method receives the coordinates of all the snake's body cells (stored in a doubly linked list LinkedList
, where the head is the snake's head and the tail is the snake's tail), the coordinates of the food, and the current direction. You need to modify the LinkedList
object in place to update the snake's body coordinates based on the current direction to complete the movement.
You can click the fullscreen button at the top right to view the game interface and code editor in full screen. Once you complete the code, the game will be fully functional. Click the "Submit" button, then the "Begin" button on the game interface to start the game. Enjoy yourself!
Snake Game Demonstration
Explanation
For beginners, moving the entire snake forward might seem like a complex algorithm, but it is not.