A classic snake game written in Python using Pygame.
In this game, the player controls a snake that moves around the screen. The snake must eat food items to grow longer and increase its score. The game ends if the snake collides with a wall or its own body.
- Python 3.x
- Tkinter
Clone the repo using
git clone https://github.com/ShellTux/Snake-Game-in-Python.git
Install tkinter using pip
pip3 install tkinter
This might not be sufficient to run on your linux machine, so install tkinter through your linux distro package manager.
platform | install command |
---|---|
Debian/Ubuntu | apt-get install python3-tk |
CentOS/RHEL | yum install python3-tkinter |
Fedora | dnf install python3-tkinter |
Arch Linux | pacman -S tk |
OpenSUSE | zypper install python3-tk |
Note that the package name may differ based on the specific version of the distribution and the package manager being used.
- Run the game using
python main.py
or
python3 main.py
or
./main.py
make sure the script has executable permissions.
- Use the arrow keys to control the snake's movement.
- Eat the food items to grow longer and increase your score.
- Avoid colliding with walls or your own body.
Inspired by classic snake games from the past. Thanks to Pygame for providing an easy-to-use library for game development in Python.