Skip to content

alucebur/snake

Repository files navigation

Snake game

This is a Python implementation of the classic game "Snake", with a menu system that lets you configure the game tweaking different settings.


How to play

  • Use the arrow keys to move the snake up, down, left and right.
  • Feed the snake with apples but avoid making it crash into its body.
  • If the snake leaves the screen, it will appear at the opposite edge.
  • Press 'P' to pause the game. Press 'P' again to unpause it.
  • Press 'G' to show a grid over the game screen.
  • Press 'Escape' to exit the game at any moment.

Features

  • Infinite screen, it makes the game more dynamic and confusing.
  • Pause, so you can get some apples from the kitchen.
  • Modern and classic look, in case you are a nostalgic.
  • Change key bindings, you don't have to use the arrow keys if you don't want to (or don't have them).
  • Set volume of music and sound effects separately.
  • TOP5 highscores, show your friends how skilled you are!

Modules used

  • os
  • math
  • json
  • copy
  • queue
  • typing
  • random
  • pathlib
  • functools
  • datetime
  • pygame

Requirements

Requires Python 3.6+ (with pip).


Installation

Clone the repository or download and extract the zip or tarball file in an empty folder on your computer.

Navigate until the recently created folder and install dependencies (this will install pygame modules):

  • Pipenv:

      pipenv install
    
  • Pip:

      pip install -r requirements.txt
    

Run the game:

  • Pipenv:

      pipenv run snake.py
    
  • Other:

      python snake.py
    

Enjoy.


Screenshots


Asset credits

  • Images:

    • icon.png: (modified from original) kungfu4000 in opengameart.org under Public Domain.
    • tile-game1.png, tile-game2.png: surfacecurve in opengameart.org under Public Domain.
    • bg-menu1.png, bg-menu1b.png, bg-menu2.png, bg-menu2b.png: Nidhoggn in opengameart.org under Public Domain.
  • Fonts:

    • AurulentSansMono-Regular.otf: Stephen G. Hartke in dafont.com under Public Domain/GPL/OFL.
    • Excalibur Nouveau.ttf: Typo-Graf in dafont.com under Public Domain.
    • HanSrf.ttf: Gerhard Großmann in dafont.com under Public Domain/GPL/OFL.
    • Jacked.ttf: Lucas Cobb Designs in dafont.com under Public Domain/GPL/OFL.
  • Sounds and music:

    • menu-accept.wav: (modified from original) Kibblesbob in soundbible.com under Public Domain.
    • menu-select.wav: (modified from original) Lisa Redfern in soundbible.com under Public Domain.
    • snake-bite.wav: (modified from original) GregoryWeir in soundbible.com under Public Domain.
    • snake-crash.wav: (modified from original) Vladimir in soundbible.com under Public Domain.
    • menu-music.ogg: (modified from original) aldo in soundbible.com under Public Domain.
    • snake-music-Rafael-Krux.ogg: (modified from original) Rafael Krux in freepd.com (Video Game Blockbuster) under Public Domain.
  • Sprites:


License

The code of this project is Unlicensed, feel free to use it as you want.

Audios, fonts and images used in this project are under Public Domain or a free license, check credits section for more details.

Snake and apple sprites were modified from the original, and are under the following GPLv3 license:

Copyright (c) 2015 Rembound.com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

About

Python implementation of the classic "Snake" game

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages