Skip to content

WxTaco/snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terminal Snake Game 🐍

A classic Snake game implementation that runs in your terminal using Python's curses library.

Features

  • Smooth gameplay with adjustable speed that increases as you score
  • Multiple control schemes: WASD keys or arrow keys
  • Real-time scoring with display
  • Pause/resume functionality
  • Game over detection with restart option
  • Collision detection for walls and self-collision
  • Responsive terminal UI with borders and status messages
  • Food generation that avoids snake body
  • Color-coded elements (green snake, red food, yellow score)

Requirements

  • Python 3.6 or higher
  • Terminal with at least 30x10 character size
  • Unix-like system (Linux, macOS) or Windows with proper curses support

Installation

  1. Clone or download this repository
  2. No additional dependencies needed - uses Python's built-in curses library

How to Play

  1. Run the game:

    python3 snake_game.py
  2. Controls:

    • Movement: Use WASD keys or arrow keys to control the snake
    • Pause/Resume: Press Space to pause or resume the game
    • Restart: Press R when game is over to restart
    • Quit: Press Q to quit the game
  3. Objective:

    • Control the snake (@) to eat food (*)
    • Each food eaten increases your score by 10 points
    • The snake grows longer with each food eaten
    • The game speeds up slightly as your score increases
    • Avoid hitting the walls or the snake's own body

Game Elements

  • @ - Snake head
  • o - Snake body
  • * - Food
  • # - Border walls
  • Score is displayed at the top
  • Game status (PAUSED, GAME OVER) shown when applicable

Tips

  • Plan your moves ahead - the snake can't reverse direction
  • Use the pause feature (Space) to take a break and plan your strategy
  • The game gets faster as you score more points, so stay focused!
  • Try to avoid trapping yourself in corners

Technical Details

  • Built with Python's curses library for terminal graphics
  • Non-blocking input for smooth real-time gameplay
  • Collision detection for walls and self-collision
  • Dynamic food generation that avoids snake body
  • Color support for enhanced visual experience
  • Responsive to terminal resizing (minimum 30x10 required)

Troubleshooting

  • "Terminal too small" error: Resize your terminal to at least 30 characters wide and 10 lines tall
  • Colors not showing: Your terminal may not support colors - the game will still work in monochrome
  • Controls not responsive: Make sure your terminal has focus and try different keys (WASD vs arrows)

License

This project is open source and available under the MIT License.

Enjoy playing Snake in your terminal! 🎮

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published