Skip to content

captainzero93/simple-snake-python-pygme

Repository files navigation

.Py Snake Game 🐍 - Pygame

Version

A simple tutorial implementation of the classic Snake game built with Python and Pygame. Detailed manual compile instructions. Building from source may work on Mac and Linux - added a beta .PKG build for Linux (untested).

check out Pygame Snake here: https://github.com/captainzero93/simple-snake-python-pygme

check out Pygame ASCII Tetris here: https://github.com/captainzero93/ASCII-Tetris

Screenshot:

!!! [Gameplay Video] !!!

Features

  • Classic snake mechanics: eat food to grow longer!
  • Arrow keys for movement (Up/Down/Left/Right)
  • Score tracking system
  • Game over when hitting walls ( window boundaries ) or yourself
  • Simple, clean UI with color-coded elements

Requirements

  • Python 3.11 (required for precompiled wheel compatibility)
  • Pygame (pygame==2.6.1)
  • all other requirments are in the requirments.txt even if they are not needed

Compiled setup - Windows users can use the Release .exe in the Releases section, ONLY do this if you trust the source, I recommend reading the code from this repo first. Refer to the documentatiom for your Linux Distro for unzipping and instaling the beta Linux .PKG zip / file.

Manual installation & Setup

Step 1: Create Virtual Environment / Clone repo

Download and extract this repo, Install Python 11 - ensire you check 'Add to path in the installer. Open CMD from the extracted folder;

python -m venv snake_venv

or Create venv using Python 3.11 explicitly:

python -m venv snake_venv --system-site-packages

Step 2: Activate Virtual Environment

# Windows (PowerShell):
.\snake_venv\Scripts\activate.ps1

Step 3: Install Dependencies

pip install -r requirements.txt

or

pip install --user pygame==2.6.1  # Install from PyPI ( recommended ) 


or

pip install --user  "folder_with_pygame.whl package\pygame-2.6.1-cp311-win_amd64.whl"  # Replace with real path.

⚠️ Important: The wheel file requires Python 3.11. If you're using a different version, download the correct wheel or install from source.

Running the Game

From inside the folder snake.py exists;

python snake.py

Or download the self contained Windows ( or beta Linux .PKG) build in Releases. ( Only do this if you trust the source).

Controls

Key Action
Move Up
Move Down
Move Left
Move Right

RULES: You are the green snake, collect the fruit, do NOT backtrack on yourself or hit into yourself or the boundaries ( Window edges ) !

Project Structure

Extracted_files/
├── README.md                                              # This file
├── snake.py                                               # Main game logic
├── Desktop Screenshot 2025.11.15 - 01.50.30.55 - Copy.png #Game screenshot for GIT README.md  
├── LICENSE                                                # Auto-generated Apache 2.0 License
├── NOTICE                                                 # Apache 2.0 compatible attribution notice
├── snake2.gif -                                           # Gameplay footage for GIT README.md  
├── video-icon-13.png -                                    #Icon
├── requirments.txt -                                      #Requirments file for building

├── 
├── .gitignore - Allows release files over 25 mb, the game is just below 30mb compiled
     

Technical Details

  • Built using Python 2.11 for compatibility with pygame
  • Uses a simple grid-based movement system
  • Score increases by a point per food item eaten
  • Game ends when snake collides with wall or itself
  • Only 139 lines of code - including comments!

Note: This implementation requires the precompiled wheel file (pygame-2.6.1-cp311-win_amd64.whl) due to Windows-specific build requirements. Do not attempt to compile from source on Python 3.12+ as it will fail. The reccomended way to instal pygame-2.6.1-cp311-win-amd64.whl is pip install --user pygame==2.6.1 ( Installs from PyPI )

Again, Windows users can use the Release .exe in the Releases section, ONLY do this if you trust the source, I recommend reading the code from this repo first. Refer to the documentatiom for your Linux Distro for unzipping and instaling the .PKG zip / file.

Attribution

This project is licensed under Apache 2.0. See the NOTICE file for specific attribution requirements when creating derivative works.

ko-fi

Version: 0.3 | Author: captainzero93 |

GitHub: https://github.com/captainzero93/

About

Simple 'Snake' imitation game using Pygame on 3.11

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages