Skip to content

ImKennyYip/snake-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

How to code a snake game in Python for beginners! Learn how to create a game of snake in Python using tkinter graphics library. Throughout the tutorial, you will learn how to create a graphical user interface (GUI) to display the Snake game, create the game loop, listen for Key presses to move the snake, use a list to store the snake's segments, and check collision and out of bounds for game over.

How to setup Python with Visual Studio Code

snake-python-demo

Homework:

You can continue working on this project if you like. One feature you can add is a keyListener in change_direction to restart the game every time there is a game over. ex) if (e.keysym == "space" and gameOver). Inside this conditional statement, you should reset the game to default (clear snake_body, set velocityX, velocityY, score to 0, etc). Another feature you can add after this is keep track of the high score and paint it below the current score. For this you will need a variable to keep track of high score.