- Snake Game is a video game genre where the player maneuvers a growing line that becomes a primary obstacle to itself.
- The concept originated in the 1976 two-player arcade game Blockade from Gremlin Industries, and the ease of implementation has led to hundreds of versions (some of which have the word snake or worm in the title) for many platforms. 1982's Tron arcade game, based on the film, includes snake gameplay for the single-player Light Cycles segment.
- After a variant was preloaded on Nokia mobile phones in 1998, there was a resurgence of interest in snake games as it found a larger audience.
- The player controls a dot, square, or object on a bordered plane. As it moves forward, it leaves a trail behind, resembling a moving snake.
- In some games, the end of the trail is in a fixed position, so the snake continually gets longer as it moves.
- In another common scheme, the snake has a specific length, so there is a moving tail a fixed number of units away from the head. The player loses when the snake runs into itself.
- A sole player attempts to eat items by running into them with the head of the snake. Each item eaten makes the snake longer, so avoiding collision with the snake becomes progressively more difficult.
- There are many languages from which Snake Game can be developed.
- I used
python
to develop this game.
- I used
- Again, there are many methods in which we can develop the game in Python.
- I used mainly
turtle
module to develop this game. - Used
random
to get random co-ordinates of snake-food. - Used
tkinter
to create a GUI.
- I used mainly
- Turtle.
- Tkinter.
- Random.
turtle
is a Python feature like a drawing board, which lets us command a turtle to draw all over it! We can use functions like turtle.forward(…) and turtle.right(…) which can move the turtle around.
pip install turtle
https://docs.python.org/3/library/turtle.html
Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter
is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to create the GUI applications. Creating a GUI using tkinter is an easy task.
pip install tkinter
https://docs.python.org/3/library/tkinter.html
Below is the screenshot showing that:
Below is the screenshot showing the same:
Below sreenshot shows how length has increased to that of last screenshot:
Below Screenshots shows such condition:
- Fork the repository by clicking the FORK button which can be found on the top-right side of the screen.
- Open the terminal as Administrator and run the below command:
git clone https://github.com/rohithvkamath/Snake-game.git
code .
git branch -m <branch_name>
git add -p
git commit -m "<your message here>"
git push origin <your_branch_name>
- Adding a better GUI using
tkinter
module. - Adding a code to calculate the score and display it in real-time in the window.
- and many more.