0% found this document useful (0 votes)
45 views8 pages

Snake

This document summarizes how to build a snake game in Python using the turtle module. It discusses importing necessary modules like random and turtle, creating the game window, defining variables, controlling the snake's movement with arrow keys, increasing the snake's length when it eats food, and ending the game if the snake collides with itself or the wall. An overview explains how turtle is used to generate shapes and graphics and random is used to place food randomly. Steps provided include installing Pygame, importing modules, setting up the game window, tracking score, creating the welcome screen, defining variables, handling collisions, and controlling the snake. Pictures show how the snake is drawn pixel by pixel using the pset command and directional buttons change its

Uploaded by

Ravi Raushan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views8 pages

Snake

This document summarizes how to build a snake game in Python using the turtle module. It discusses importing necessary modules like random and turtle, creating the game window, defining variables, controlling the snake's movement with arrow keys, increasing the snake's length when it eats food, and ending the game if the snake collides with itself or the wall. An overview explains how turtle is used to generate shapes and graphics and random is used to place food randomly. Steps provided include installing Pygame, importing modules, setting up the game window, tracking score, creating the welcome screen, defining variables, handling collisions, and controlling the snake. Pictures show how the snake is drawn pixel by pixel using the pset command and directional buttons change its

Uploaded by

Ravi Raushan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

P

PROJECT
ON
SNAKE GAME

Snake games are made from python code


SUBMITTED BY

NAME SID
Ravi Raushan 100056
Dildar Shahnawaz 90702
Prakash Chandra kumar 100554

Course :- B-tech (CS)

Subject :- python
INTRODUCTION

The following game writing in python based on the


game called snake which has been around since the
earliest days of home computing and has re-
emerged in recent years on all platforms.

The snake in the snake game is controlled using four


directions, and if the snakehead hits the wall or hits itself,


then the snake dies, and the game will be ended with the
score.

The player’s main aim in the game is to achieve maximum


points as possible by collecting the food.

So, if you are a beginner and you learned about turtle


then you can use this module for making a snake game.
PROJECT FILE STRUTURE

 
Steps to follow to built snake game in python:

Installing Pygame

Importing random and Pygame

Creating the game window

Displaying score on the screen

To make the welcome screen

Defining the variables that will be used in the program

If the game is over

To play the game with the help of arrow keys

Eating the food and displaying score

Increasing the length of snake

If the snake collides with itself or the wall

Plotting the snake
Overview of Snake game in Python turtle


Turtle – It is a pre-installed library in python which is used for creating shapes, picture, and game.


Time – It is used for counting the number of seconds elapsed since the epoch.


Random – This module is used to generate random numbers in python using the random module.


penup() – It stops drawing of the turtle pen.

speed() – It is an integer value in the range 0 to 10. So, 0 is fastest, 10 is fast, 6 is normal, 3 is slow, and 1 is slowest. If no argument is given,

returns the current speed.


color() – It returns or set pen color and fill color.


shape() – It set turtle shape to the shape of a given name.


hideturtle() – It makes the turtle invisible.


xcor() – Return the turtle’s x coordinate.


ycor() – Return the turtle’s y coordinate.
Create a snake game using Python turtle (Step by Step) pictures
How the Snake Games Draws the Snake.

The snake is drawn one pixel at a time.


Uses the pset command .

User click on one of the paths directional command buttons to change the
path of snake.
SUBMITTED TO:-

THANK YOU

You might also like