This is the classic Snake game written in Python 3 using Pygame. It was made by very loosely following this YouTube tutorial made by Clear Code. My implementation has a handful of changes and I continued to extend it beyond what that video covers.
- Use the
arrow keys
to move the snake - Press
r
to start a new game - Eat apples to gain points and grow the snake
- Hitting a wall or yourself kills the snake and ends the game
- Go to the Releases page
- Download the version you want (get the latest if unsure)
- Extract the zip folder somewhere
- Run
snake.exe
These pre-packaged releases only run on Windows! They are made with PyInstaller and do not require any prerequisites.
- Check that you have the required prerequisites
- Download the
snake.py
script,Font
folder,Graphics
folder, andSound
folder (directory structure should look like it does below) - Run the
snake.py
script in a Python 3 interpreter
.
├── Font
│ └── PoetsenOne-Regular.ttf
├── Graphics
│ ├── apple.png
│ ├── body_bl.png
│ ├── body_br.png
│ ├── body_horizontal.png
│ ├── body_tl.png
│ ├── body_tr.png
│ ├── body_vertical.png
│ ├── head_down.png
│ ├── head_left.png
│ ├── head_right.png
│ ├── head_up.png
│ ├── tail_down.png
│ ├── tail_left.png
│ ├── tail_right.png
│ └── tail_up.png
├── Sound
│ └── crunch.wav
└── snake.py
I originally used:
- Python 3.9.2
- Pygame 2.0.1
- SDL 2.0.14 (bundled with Pygame)
I did not test any older versions of the listed software. Latest release is using:
- Python 3.11.2
- Pygame 2.3.0
- SDL 2.24.2 (bundled with Pygame)