Skip to content

conorgregson/snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Snake (Python + Tkinter)

A modern take on the classic Snake arcade game, built with Python and Tkinter. It includes dynamic themes (Classic, Ocean, Sunset, Retro), animated title reveal, score + session high score, and a reset flow from a Game Over screen.


Features

  • 4 themes via dropdown: Classic / Ocean / Sunset / Retro
  • Animated title and start prompt
  • Arrow-key controls with smooth, timer-based movement
  • Score + session high score (resets when the app closes)
  • Reset button shown on Game Over
  • Window-centering and fixed-size canvas (1000×700)

Controls

  • Space — Start the game
  • Arrow Keys — Move (Up/Down/Left/Right)
  • Theme menu — Change theme (resets the game)
  • Reset button — Appears after Game Over

Note: WASD and pause aren’t implemented in the current code.


Requirements

  • Python 3.8+
  • Tkinter (bundled with most Python installers)
    • Linux: you may need to install it separately, e.g. sudo apt install python3-tk

Run Locally

# 1) Clone
git clone https://github.com/your-username/snake-tkinter.git
cd snake-tkinter

# 2) Run
python snake.py
# or: python3 snake.py

How It Works (quick tour)

  • Constants: tune board size, speed, and cell size at the top of snake.py
  • Themes: managed by THEMES + apply_theme(theme_name) which resets the game, recolors the canvas, and redraws the snake/food.
  • Game loop: next_turn() updates the snake’s head position, handles growth when eating food, and checks collisions before scheduling the next tick.
  • Entities:
    • Snake class stores coordinates and canvas rectangles
    • Food class spawns a new food circle at a random grid location
  • Input: Arrow keys are bound via window.bind(...); Space starts the run.
  • Game Over: clears the canvas, shows a Game Over banner, and a Reset Game button that re-applies the current theme.

Customize

  • Add a theme: extend THEMES:
    THEMES["Neon"] = {"bg": "#0A0A0A", "snake": "#39FF14", "food": "#FF2079"}
    It will automatically appear in the dropdown.
  • Change speed or grid: tweak SPEED and SPACE_SIZE.
  • Board size: update GAME_WIDTH / GAME_HEIGHT.

Roadmap / Ideas

  • Pause/resume (P)
  • WASD support + key repeat throttling
  • Persistent high scores (JSON or SQLite)
  • Sounds and music
  • Difficulty levels
  • Obstacles and power-ups

Author

Made by Conor Gregson


License

This project is open-source and available under the MIT License. See the LICENSE file for details.


Credits

Built with Python’s standard Tkinter GUI toolkit. Inspired by the classic Snake arcade game.

About

Classic Snake game built with Python and Tkinter, featuring themes, real-time input handling, and persistent high scores.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages