Games & Experiments

Python Snake Game

A compact pygame implementation of Snake with grid movement, collision rules, scoring, and restart flow.

This was a small weekend project to learn pygame by rebuilding Snake from first principles. The game runs on a 16px grid, updates at a fixed tick rate, and keeps the logic deliberately explicit: direction changes, body movement, food spawning, collision detection, score tracking, and restart handling are all implemented in one readable Python file.

What it covers

  • Pygame's event loop and keyboard input handling.
  • Grid-aligned movement with prevention for instant reverse turns.
  • Food spawning, score updates, and snake growth.
  • Boundary and self-collision checks.
  • A simple game-over state with keyboard restart.

It is intentionally simple, but it captures the core loop that sits underneath most real-time games: read input, update state, apply rules, redraw, and repeat at a predictable frame rate.