Skip to content

Pawelo112/Simple-snake-game-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐍 Simple snake game - Python

Screenshot from the game.

📖 Description and rules

This is a simple snake game that I made in Python using Turtle module, during 100 days of code Python course.

The rules of snake:

  • 🎮You control the snake with arrows to move up⬆️, down⬇️, left⬅️ and right➡️.
  • ⛔You cannot move in the opposite direction - for example you cannot move down if head of the snake is heading up.
  • 🍎You collect the food, which position is randomized - each piece of food gives you one point and makes snake longer each time.
  • 🏆Your main goal is to have the highest score possible (you can see your current score and saved high score at the top of the screen).
  • The game is over when:
    • Snake collides with the wall.
    • Snake collides with its own body.
  • 🔁When you lost, the game immediately restarts, placing new snake at the starting position and resets you score.
  • 🛑To quit the game you have to close the window or stop the application.

📁 Files description

  • main.py - Main file of the app. Here the objects for food, snake, scoreboard and screen are created and collision is being detected. From the important things you can edit screen size here or change the speed of the game.

  • food.py - Here the food object is being represented and its position and color is being randomized. You can add any colors to the colors list as long as Turtle module supports it.

  • scoreboard.py - This file contains all methods connected to the scoreboard like updating score and displaying GAME OVER screen.

  • snake.py - This file collects all methods and things connected to the snake object like creating small snake at the start and adding new "segments" of it, which is used after eating one piece of food by snake.

  • data.txt - This text file contains your high score, which is loaded when you start the game.

🖥️ Usage

You can find the latest release here: releases
You can download exe file to play and test the game or whole source code to edit this game on your own 🤓.

Unfortunately windows defender and other anti-viruses detects Snake.exe file as a virus because it was made with pyinstaller and it is known issue with exe files made with it and there isn't much that I can do about it.

📝 License

Copyright © 2024 Paweł Marcinkowski.
This project is MIT licensed.

About

Simple snake game made in Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages