5.1 Basics of Snake Game
The snake game is a classic video game where the player maneuvers an onscreen snake, often represented as a line on a bordered or non-bordered screen. The snake grows in length and gets points when it eats the food, and the primary obstacle for its movement is the snake itself.
In this demo, the game has the up, down, right, and left swipe commands to steer the snake towards the food. The food is provided at random coordinates on the screen for the snake to eat. Every time the snake eats the food, its length is increased by one element. When the snake collides with itself, the game is over.