DEV Community

Wojtek Gołdych
Wojtek Gołdych

Posted on

First Python project! Snake game 🐍

Image description

The genesis of my snake game.

As I am a beginner on my journey towards learning Python. I thought that creating a snake game would be a perfect way to learn some useful skills and putting to use what I have learned already.

What makes a great snake game?

That was my first question before even opening the IDE. So while I was pondering about that I remembered my first time playing the game. Then I started to break the game logic into small parts.

I created a list of things that a snake game must have. If you are also a beginner in Python programming I challange you to also try making this fun project. Also, feel free to expand the list with new features.

The perfect snake game should have:

  1. A window that opens and a space on the screen for the snake to move on.

  2. Snake body that consist of rectangles and that the body is growing when the snake eats the fruit.

  3. The logic to move the snake around the screen with arrow keys for example.

  4. The rules when the game ends. As in the classic snake game it would be when the snake eats itself or hits the wall/border of the window.

  5. The mechanism that makes fruit rectangles appear in random places on the screen.

  6. Score that is showing continuously on the screen and is incremented whenever snake eats the fruit.

  7. A game over text with the final score.

I think that would be the basics of a snake game. Of course you could always make it more advanced, add some pause option with escape button or make a menu that shows up at first.

My version of the snake game

Below you will find a link to my GitHub account with my version of the snake game. It is basic and not sophisticated enough. I will probably add some features in the future but for now I want to go further into learning and make more projects.

My snake game

Please feel free to leave any feedback about the snake game and the code behind it. I would also love to hear from you if you managed to create similar projects it is always fun to see other people approach to the same problem.

Top comments (0)