Snake game in Python
The purpose of this project is create a version of the game Snake in Python
Snake is a video game concept in which the player moves around a line (the snake) which grows in length
The player controls the snake's head on a screen by using up, down, left, and right arrow keys. At the start of the game, the head of the snake is centered in the screen. A piece of purple food is randomly placed on the screen. The player moves the snake to the food to grow the snake in length. When a piece of food is consumed, the snake's body increases by 1 block, and the score is increased.
As the snake's head moves forward, its body follows. The player loses when the snake runs into the screen border or itself.
- Install pygame
$ pip install pygame 2.0.1
- Run snake.py to run the game
$ python snake.py
A pygame window with the title ‘SNAKE’ should pop up. The snake starts as a green block of size 1. Press the up, down, left, or right arrow key to begin moving the snake. Once the snake is moving, it cannot be stopped. Direct the snake to the purple block, which is the food.
$ python3 -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt
$ python3 snake.py
Laura Kocubinski laurakoco
- Boston University MET Master of Science Computer Science Program
- MET CS 521 Information Structures in Python