Skip to content

rakshanda33/Snake-Game

Repository files navigation

Snake Game 🐍

A classic Snake game built with Python and Pygame featuring multiple food variations and smooth gameplay.

Features

  • Classic Snake Gameplay: Control the snake using arrow keys
  • Multiple Food Types: 6 different food images that appear randomly
  • Score Tracking: Keep track of your current score
  • Game Over Detection: Collision detection with walls and snake body
  • Smooth Animation: 60 FPS gameplay with responsive controls
  • Sound Effects: Eating and collision sounds (optional)

Screenshots

Snake Game

Requirements

  • Python 3.x
  • Pygame library

Installation

  1. Clone this repository:

    git clone https://github.com/rakshanda33/Snake-Game.git
    cd Snake-Game
  2. Install required dependencies:

    pip install pygame
  3. Run the game:

    python snakeNew.py

How to Play

  • Use Arrow Keys to control the snake direction
  • Eat food to grow longer and increase your score
  • Avoid hitting the walls or your own body
  • Press any key to restart after game over

Game Controls

  • ↑ Arrow Key: Move Up
  • ↓ Arrow Key: Move Down
  • ← Arrow Key: Move Left
  • → Arrow Key: Move Right
  • Any Key: Restart game after game over

File Structure

SnakeGame/
├── snakeNew.py          # Main game file
├── snake.py             # Alternative version
├── food.png             # Food image 1
├── food1.png            # Food image 2
├── food2.png            # Food image 3
├── food3.png            # Food image 4
├── food4.png            # Food image 5
├── food5.png            # Food image 6
├── requirements.txt     # Python dependencies
├── Sounds/              # Sound effects folder (optional)
│   ├── eat.mp3         # Eating sound
│   └── wall.mp3        # Collision sound
└── README.md           # This file

Technical Details

  • Game Window: 600x600 pixels
  • Grid Size: 20x20 cells
  • Cell Size: 25x25 pixels
  • Frame Rate: 60 FPS
  • Snake Speed: Updates every 200ms

Customization

You can easily customize the game by modifying these variables in snakeNew.py:

  • cell_size: Size of each grid cell
  • number_of_cells: Number of cells in the grid
  • OFFSET: Border around the game area
  • GREEN and DARK_GREEN: Game colors

Contributing

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/improvement)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add new feature')
  5. Push to the branch (git push origin feature/improvement)
  6. Create a Pull Request

License

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

Author

Rakshanda Noor - GitHub Profile

Acknowledgments

  • Built with Python and Pygame
  • Inspired by the classic Snake game
  • Thanks to the Pygame community for excellent documentation

Enjoy playing! 🎮

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages