Feeling nostalgic for retro games? No worries, in this repository you will find a main.py file that allows you to dive into your childhood memories and play the most famous video game of all times: the Snake Game 🐍
But don't leave me yet, because there are many more things you need to know and discover and you will be required to give some specific parameters to the program. Let's dive in!
If you run the program, executing the main file with: $ python main.py -u playername a window with a small cubic segment moving around appears on your screen, and that's your time to play!
Note: the project requires the following modules to run:
turtle,argparse,sqlite3,unittest2,colorama,random,os,csv.
You can use the arrow keys of your computer keyboard to move the snake around and try to eat the pieces of food in its path so it can grow in length. For each piece of food the snake eats, an additional point is added to your score but as in the real game, every time the snake collides with the walls of the window or its own tail, then it's GAME OVER 👾❌
Don't worry though, you can play as many times as you want and your score will be saved together with your competitors' ones, so you can always check your ranking and try to beat their score! We have also provided you with the possibility to personalise your game, choosing the colour of the background or the snake, and even the shape of the food, but don't worry I will explain everything step by step!
To use Snake Game, you need Python 3.x and pip. Clone the repository and install the required packages:
git clone https://github.com/giuntac/Snake-Game.git
cd Snake-Game
pip install -r requirements.txt
As previously explained in the introduction, some commands are required in order to run our main script.
When we run python main.py we can play, but without saving our score and username.
On the other hand, have two possibilities:
- insert the username and store our username and score;
- see the statistics of the scoreboard.
These two options are possible thanks to the following commands:
-
Positional arguments
-u: adds the username
-
Optional arguments
-c: checks for the username and returns the score-m: returns max score-l: prints all users and their related scores
If you want to change the usability features (background color, snake color, food color, food shape) you have to execute $ python configurator.py.
After that, you will be asked to choose between:
y(yes) you will be able to change background color, snake color, food color, and food shape;N(no) you will exit from this command.
Accordingly with your choices you can now start playing by typing $ python main.py -u playername with the new features (if you chose y), on the other hand you will play with default features.
Tests of the configurator.py file are here: package_name/tests/ .
You will find one module test_configurator.py.
To run them from the main folder use: python -m unittest2 -v -b package_snake/tests/test_configurator.py .
You can find the authors on LinkedIn:
GPL
Thank you for playing, we hope you have fun! 🎮🏆
