[go: up one dir, main page]

0% found this document useful (0 votes)
58 views31 pages

Snake Game Final Report

Snake game semster mini project with complete report detailed information with references.

Uploaded by

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

Snake Game Final Report

Snake game semster mini project with complete report detailed information with references.

Uploaded by

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

CHAPTER 1

INTRODUCTION

1.1 PYTHON
The game is developed using Python. Python is an interpreted, object-oriented, high-level
programming language with dynamic semantics. Its high-level built-in data structures,
combined with dynamic typing and dynamic binding. Python's simple, easy to learn syntax
emphasizes readability and therefore reduces the cost of program maintenance. Python
supports modules and packages, which encourages program modularity and code reuse. The
Python interpreter and the extensive standard library are available in source or binary form
without charge for all major platforms and can be freely distributed.

I know you’ve all played Snake, and I’m sure you never wanted to lose. As kids, we all loved
looking for cheats so we’d never see the “Game Over” sign, but as techies, I know you’d want
to make this “Snake” dance to your beats.

Have you ever thought about being in charge of a moving snake, guiding it through a maze that
keeps changing, and feeding it tasty food to make it grow longer? well, Building the Snake
game in Python lets us be creative and improve our computer skills simultaneously. Python is
the best language for this project because it is easy to learn and can be used in many ways.
Don’t worry if you’ve never used Python before. We’ll walk you through each step of the
process all in this article on Snake Game in Python.

Snake game is one of the most popular arcade games of all time. In this game, the main
objective of the player is to catch the maximum number of fruits without hitting the wall or
itself. Snake game is one of the most popular arcade games of all time. In this game, the main
objective of the player is to catch the maximum number of fruits without hitting the wall or
itself. Creating a snake game can be taken as a challenge while learning Python or Pygame. It
is one of the best beginner-friendly projects that every novice programmer should take as a
challenge. Learning to build a video game is kinda interesting and fun learning.

We will be using Pygame to create this snake game. Pygame is an open-source library that is
designed for making video games. It has inbuilt graphics and sound libraries. It is also
beginner- friendly, and cross-platform.

We will be validating the keys that will be responsible for the movement of the snake, then we
will be creating a special condition that the snake should not be allowed to move in the
opposite direction instantaneously.

1
After that, if snake and fruit collide we will be incrementing the score by 10 and new fruit
will be spanned.
After that, we are checking that is the snake hit with a wall or not. If a snake hits a wall we
will call game over function.
If the snake hits itself, the game over function will be called. And in the end, we will be
displaying the scores using the show_score function created earlier

1.2 TKINTER:
Python offers multiple options for developing GUI (Graphical User Interface). Out of all the
GUI methods, tkinter is most commonly used method. It is a standard Python interface to the
Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and easiest way to
create the GUI applications. Creating a GUI using tkinter is an easy task. Tkinter includes a
number of Python modules. The two most important modules are the Tkinter module itself,
and a module called Tkconstants. The former automatically imports the latter, so to use
Tkinter, all you need to do is to import one module.

1.3 PYGAME:
Game programming is very rewarding nowadays and it can also be used in advertising and as a
teaching tool too. Game development includes mathematics, logic, physics, AI, and much
more and it can be amazingly fun. In python, game programming is done in pygame and it is
one of the best modules for doing so

1.4 SNAKE GAME:


Although the concept of snake-based games originated in 1976, there was a resurgence of
interest only after a variant was preloaded on Nokia mobiles in 1998. We have optimized the
exact same variant using Python programming language. When user hits 'start' a snake is
generated at predefined position on the canvas and a piece of food is generated at a random
position. We can control snake movements using "UP"," DOWN"," RIGHT" and" LEFT" keys
of our keyboard. When head of snake collides with the piece of food, the piece of food
disappears, snake size increases by one block and a new food is generated at some random.
position on canvas other than the areas covered by snake parts.

If you press any other key, the program will continue to run as normal. The code starts by
checking to see if the player has pressed two keys at the same time. If they have, the code
changes the direction of the snake. Next, the code checks to see if either key was pressed in a
different direction than expected. If it was, then the code adjusts the position of the snake
accordingly.

2
Finally, it updates how big the snake’s body is getting.

The code will check if the two keys being pressed at the same time are either ‘UP’ or
‘DOWN’. If they are, then the direction of the snake will be changed accordingly.

1.5 DESCRIPTION OF GAME:


The current snake game is a single player game. The game interface is built in 2D format. The
game is displayed in the pygame window. Here, it consists of two points where one is movable
while the other is fixed. The movable point is the snake while that of the point at fixed location
is the food. Whenever the snake gets the food the length of snake increases by one. The speed
of the snake can be altered from the code. The player controls a long, thin creature, resembling
a snake, which roams around on a bordered plane, picking up food (or some other item), trying
to avoid hitting its own tail or the edges of the playing area. Each time the snake gets a piece
of food, its tail grows longer by one, Also, the player score increases by one and making the
game increasingly difficult. The user controls the direction of the snake's head (up, down, left,
or right), and the snake's body follows.

A console window is created as soon as the game starts. The game will terminate if the snake
head collides with any of the window's boundaries or with its own tail. Whenever the game is
finished, the score is displayed in the centre of the window. The GUI is developed using
pygame and various image files are used to create the interface. The interface is divided into
various sections and each section lead up to different functionalities. The limitations with the
existing system is that the game has no dedicated storage allocated to store the user's
information and performance statistics. The game has no information regarding the user so
every time the game is executed it is like the game is running for the first time.

1.6 SNAKE GAME LOGIC:


In this snake game, if the player hits the boundaries of the screen, then he loses. To specify
that, I have made use of an 'if' statement that defines the limits for the x and y coordinates of
the snake to be less than or equal to that of the screen. Also, make a not over here that I have
removed the hardcodes and used variables instead so that it becomes easy in case you want to
make any changes to the game later on.

In pygame, we have this thing called Rect, Rects make collision detection easy, You can also
use Rect on images, any rectangular object works. It can also be circular. Now to make a Rect,
we have to use Pygame.Rect() method We have to pass in the x coordinate as the first
argument, y coordinate as the 2nd argument, and width and height as the 3rd and 4th argument
respectively In our case, we first pass the snakes x coordinate, y coordinate, it's width and
height Now rects have a lot of methods available, one is colliderect(),

3
This method takes another Pygame. Rect() as argument and checks if they two collide with
each other In our case, we pass fruit_pos transforming as Rect to the colliderect method. If this
returned true, fruit_spawn will be true, so new fruits will be generated and the score will be
increased. The game will terminate if the snake head collides with any of the window's
boundaries or with its own tail.

4
CHAPTER 2:

LITERATURE REVIEW

2.1 LITERATURE SURVEY

The history of the Snake game goes back to the 1970's, the concept originated in the 1976
arcade game Blockade, and its simplicity has led to many implementations. However, it was
the 1990's when the game took on the look that we will be using. It was sold under numerous
names and many platforms but probably gained widespread recognition when it was shipped
as standard on Nokia mobile phones in the late 1990' The first published Nokia, for
monochrome phones. It was programmed in 1997 by Taneli Armanto of Nokia and introduced
on the Nokia 6110,

The game involves controlling a single block or snakehead by turning only left or right by
ninety degrees until you manage to cut a block. When you get the block, the Snake grows an
extra block or body segment.

If, or rather when, the snake bumps into the edge of the screen or accidentally casts himself the
game is over. The more blocks the snake eats the higher the score.

2.2 MODULES

PyGame
Py game is a cross-platform set of python modules designed for writing video games.
It includes computer graphics and sound libraries designed to be used with the Python
Programming language.
To install the library, you can use pip installer from the command line:
pip install pygame
import pygame
Python time module

5
Python has a module named time to handle time-related tasks. To use functions defined in the
module, we need to import the module first.

Here's how:
import time
Python random module
Python has a built-in module that you can use to make random numbers
import random

6
CHAPTER 3

PROBLEM DEFINATION

3.1 DESCRIPTION OF PROBLEM DOMAIN

The core focus of our project was to determine which algorithms would be more effective in
a hard real-time environment. The domain in this case is the Snake Game, which will, in turn,
attempt to identify an, or even the, algorithm that can not only play the game but compete
with human players. The Snake Game is a classic arcade style game where it is a single-
player game but the focus is to achieve the highest score possible thus competing with
yourself and others

Fig 3.1.1: Red Circle Is Apple And Green Rectangle Is Snake

To play the game one controls a snake by selecting one of the cardinal directions that the
snake will move in. In order to score points you must direct the snake to an apple, there is only
one apple in the game at time. The snake then eats the apple and increases in length by
onesquare or unit. The game ends when the snake runs into either the boundaries of the play
area or itself, the trailing snake body. The domain provides a very interesting problem given
that the snake always moves after a given timing delay and the snake continually grows in
size. The delay is the feature that really makes the game difficult because if you do not react
fast enough the snake will continue moving in the last direction given. This causes the player
to try to act as quickly as possible before the snake runs into an obstacle. Also because the
snake is constantly trailed by its tail (being the main obstacle) any move taken cannot be
undone or immediately

7
back tracked. So if you were to make a wrong turn into a dead end there is no way to reverse
that move to back out of the loop.
Although with every move your tail moves thus creating a situation where a dead end or
closed loop will no longer be a dead end after x moves. The apple also can be very tricky
since you cannot know where the next apple position will be and this makes it difficult to go
straight for the current apple without thinking of how to gept into a good position for the next
apple.

3.2 PROBLEM STATEMENT


The problem is to design a Snake Game which provides the following functionalities:

1. Snakes can move in a given direction and when they eat the food, the length of the snake
increases.

2. When the snake crosses itself, the game will be over.

3. Food will be generated at a given interval.

The main classes that can be used are:

1. Snake
2. Cell
3. Board
4. Game

8
3.3 PROBLEM DEPICTION

9
10
3.4 OBJECTIVE

Snake game is one of the most popular arcade games of all time. In this game, the main
objective of the player is to catch the maximum number of fruits without hitting the wall or
itself.

Creating a snake game can be taken as a challenge while learning Python or Pygame. It is one
of the best beginner - friendly projects that every novice programmer should take as a
challenge.

Learning to build a video game is kinda interesting and fun learning.

11
CHAPTER 4

SYSTEM DESIGN

To create a Snake game that allows users to control the movement of a snake on a screen, to
get points for eating food and avoiding running into the walls or the growing tail of the snake
itself. In this problem, we want to write a game where a graphical representation of a snake
moves across the screen. When it encounters a piece of food, the snake grows longer and we
gain a point. If it hits the wall we die.

To write this program we are going to need:

1. A way of representing the sake of representing the food.

2. A way to display the score,

3. A way for our instructions to reach the snake

4. A way to know when we've run into something and died

Our system is going to involve working with both hardware and software, and so we will
need to understand what we have available in hardware that can assist us.

If we build our software so that the snake is controlled by directional arrows on the keyboard.
Now that understand how our hardware will work in the design of our system, let's move on
to starting the design of our software system

12
4.1 SOFTWARE DESIGN

• We are going to use an object-oriented approach and provide some detail here. We have to
think about the Classes that we want to build, with the associated variables and functions that
will make sense for the development.

Let's start by looking at the snake itself, the hero of the game. The stake has a location on the
screen, and contains multiple visual elements, as it can grow, and the snake's head is
connected to the rest of the snake and the stake's body follows it around the screen. If the
snake "eats" food, it grows. The snake moves in a very precise way. Based on what the user
types, the snake will move in a given direction. Every time the snake moves, the head will go
in the new direction, and every piece of the snake will move up, by occupying the space that
was formerly occupied by the piece in front of it.

• To grow in size, the snake has to cat food. How can we show the snake eating? The simplest
answer is that if the head of the snake and the food are in the same place, we consider that the
snake eats the food. This means that we have to know where the food is. When it's eaten, it
disappears, the snake grows, and the food shows up somewhere else. But we also wanted to
show a score, so we need a variable to keep track of that as well. In this case, we'll create a
Scoreboard class where we can increase the counter value and display it.

4.2 FUNCTIONAL REQUIREMENTS

Here are the requirements (functional requirements for how the snake moves.

1. The snake must appear to move around the screen

2. The snake must turn in response to user input

3. The snake will increase in length if it eats food

4. The snake will die if it runs to the walls

5. The snake never stops movin

13
4.3 NON-FUNCTIONAL REQUIREMENTS

The primary features of IT projects involve implementing like an application, a piece of


infrastructure, a patch

In this specific context functional requirements tells us about what project does when
interacted, whereas non-functional requirements describe about the bounds of performance
should be:

I. Robustness:

Robustness is nothing but its ability to tolerate the effects of the system's fictional body. And
it can also be defined by its system's ability that it can withstand change without transforming
its initial stable configuration.

II. Reliability:

The system is trustworthy and it is consistently good in performance. It can also be stated as
the system performs the function without any failure under certain conditions and specified
period of time.

III. Availability:

The system is available 247, Availability and Reliability are directly proportional as
reliability increases availability also increases. The ser can have access to the system all the
time

IV. Reusability:

The system can be used any number of times by the specific user. And the reusability is
consistent, adaptable and stable

V. Effectiveness:

The algorithm is capable of producing desired results or it has the ability to provide better
results.

14
4.4 SOFTWARE REQUIREMENT SPECIFICATION

4.4.1 SRS

Software Requirement Specification (SRS) is the starting point of the software developing
activity. As the system grew more complex it became evident that the goal of the entire
system cannot be easily comprehended. Hence the need for\
the requirement phase arose. The software project is initiated by the client. The SRS is the
means of translating the ideas of the minds of clients (the input) into a formal document (the
output of the requirement phase) The SRS phase consists of the activities.

4.4.2 Problem/Requirement Analysis.

The process is order and more nebulous of the two, deals with understanding the problem, the
constraints.

4.4.3. Requirement Specification

Here, the focus is on specifying what has been found giving analysis such as representation
specification languages and tools, and checking the specifications are addressed during this

The Requirement phase terminates with the production of the validate SS document.
Producing the SRS document is the basic goal of this phase.

4.4.4. Role of SRS

The purpose of the Software Requirement Specification is to reduce the communication gap
between the clients and developers. Software Requirement Specification is the medium which

15
makes sure which the client and user needs are accurately specified. It forms the basis of
software development.

A good SRS should satisfy all the parties involved in the system.

The SRS document is the basic goal of this phase. The purpose of the Software Requirement
Specification is to reduce the communication gap between the clients and the developers.

The developer is responsible for asking for clarifications, where necessary, and will not make
alterations without the permission of the client

4.5 HARDWARE AND SOFTWARE REQUIREMENTS

4.5.1 Software Requirements

The development and deployment of the application requires the following general and specific
minimum requirements for software:

• Programming Language Translaties-Python 18

IDE-Jupyter Notebook Operating System used Windows 10.

4.5.2 Hardware Requirements

The development and deployment of the application requires the following general and
specific minimum requirements for hardware: Processor-(32-bit or 64-bit) RAM (4 GB).\

16
CHAPTER 5

IMPLEMENTATION

5.1 PYTHON

Python is an object-oriented, high level language, interpreted, dynamic and multipurpose


programming language.

Python is easy to leam yet powerful and versatile scripting language which makes it attractive
for Application Development Python's syntax and dynamic typing with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
Python supports multiple programming patterns, including object oriented programming,
imperative and functional programming or procedural styles Python is not intended to work on
special areas such as web programming.

That is why it is known as multipurpose because it can be used with web, enterprise, 3D CAD
ere We don't need to use data types to declare variables because it is dynamically typed so we
can write a=10 to declare an integer value in a variable. Python makes the development and
debugging fast because there is no compilation step included in python development and the
edit-test- debug cycle is very fast.

PYTHON HISTORY

Python laid its foundation in the late 1980s.. The implementation of Python was started in
December 1989 by Guido Van Rossum CWI in the Netherlands.

ABC programming language is said to be the predecessor of Python language which was
capable of Exception Handling and interfacing with Amoeba Operating System.
Python is influenced by programming languages like
ABC language
Modula-3

17
5.2 PY-GAME

Python is the most popular programming language or nothing wrong to say that it is the next
generation programming language.

In every emerging field in computer science, Python makes its presence actively Python has
vast libraries for various fields such as Machine Learning (Numpy, Pandas, Matplotih),
Artificial intelligence (Pytorch, TensorFlow), and Game development Game programming is
very rewarding nowadays and it can also be used in advertising and as a teaching tool too.
Game development includes mathematics, logic, physics, AL, and much more and it can be
amazingly fine. In python, game programming is done in pygame and it is one of the best
modules for doing so Pygame is a cross-platform set of Python modules which is used to create
video games. It consists of computer graphics and sound libraries designed to be used with the
Python programming language. Pygame was officially written by Pete Shinners to replace
PySDL. Pygame is suitable to create client-side applications that can be potentially wrapped in
a standalone executable.

INSTALLING PYGAME:
The first thing you will need to do in order to create games using Pvgame is to install it on
your systems. To do that. vou can simply use pip install pygame

5.3 FUNCTION DESCRIPTION

Once that is done, just import Pygame and start our game development. Before moving on,
take a look at the Pygame functions that have been used in this Snake Game along with their
descriptions.

Function

Description

init()

18
Initializes all of the imported Pygame modules (returns a tuple indicating success and failure of
initializations)

display.set model()

Takes a tuple or a list us ats parameter to create a surface (tuple preferred)

update()

Updates the screen

quin()

set caption

Used to un-initialize everything

Will set the caption test on the top of the display

event.get()

Returns list of all events

Surface fill()

Will fill the surface with a solid color

time Clock()

Helps truck time

Font
SysFont()

Will create a Pygame font from the System font resources

19
5.3 IMPLEMENTATION STEPS

1. Installing pygame

2. Create the screen

3. Create the Snake

4. Moving the Snake

5. Game over when snake hits the boundaries

6. Adding the Food

7. Increasing the length of the snake & Displaying the score

5.4 WORKING ALGORITHM

Let's look at how a program to run the whole game might look.

1. Draw the playing area with bounding rectangle, set the counter to zero and display I

2. Draw the snake in a starting position,

3. Draw the food in a starting location.

4. On user input, change snake direction.

5. Move the snake one move

6. If the snake is over food, cat it, increase the score, grow, move the food.

7. else if the snake is over in a wall, die.

8. Go back to step 4

9. Until the snake die

20
CHAPTER 6

TESTING

6.1 SOFTWARE TESTING

Software testing is a critical element of software quality assurance and represents the ultimate
review of specification, design and code generation

6.1.1 TESTING OBJECTIVES

• To ensure that during operation the system will perform as per specification. TO make sure
that system meets the user requirements during operation

• To make sure that during the operation, incorrect input, processing and output will be
detected. To see that when correct inputs are fed to the system the outputs are correct To
verily that the controls incorporated in the same system as intended. Testing is a process of
executing a program with the intent of finding an error

• A good test case is one that has a high probability of finding an as yet undiscovered The
software developed has been tested successfully using the following testing strategies and any
errors that are encountered are corrected and again the part of the program or the procedure of
function is put to testing until all the errors are removed. A successful test is one that
uncovers an as yet undiscovered error.

Note that the result of the system testing will prove that the system is working correctly, It will
give confidence to system designer, users of the system.

Python is the most popular programming language or nothing wrong to say that it is the next
generation programming language.

In every emerging field in computer science, Python makes its presence actively Python has
vast libraries for various fields such as Machine Learning (Numpy, Pandas, Matplotih),
Artificial intelligence (Pytorch, TensorFlow), and Game development Game programming is
very rewarding nowadays and it can also be used in advertising and as a teaching tool too

21
Game development includes mathematics, logic, physics, AL, and much more and it can be
amazingly fine. In python, game programming is done in pygame and it is one of the best
modules for doing so Pygame is a cross-platform set of Python modules which is used to create
video games. It consists of computer graphics and sound libraries designed to be used with the
Python programming language. Pygame was officially written by Pete Shinners to replace
PySDL. Pygame is suitable to create client-side applications that can be potentially wrapped in
a standalone executable.

Installing pygame:

The first thing you will need to do in order to create games using Pvgame is to install it on your
systems. To do that. vou can simply use pip install pygame

6.2 TEST CASE DESIGN

6.2.1 White Box Testing

White box testing is a testing case design method that uses the control structure of the
procedure design to derive test cases. All independent paths in a module are exercised at least
once. I logical decisions are exercised at once, execute all loops at boundaries and within their
operational bounds exercise internal data structure to ensure their validity. Here the customer
is given three chances to enter a valid choice out of the given menu. After which the control
exits the current menu.

6.2.2 Black Box Testing

Black Box Testing attempts to find errors in following areas or categories, incorrect or
missing, functions interface error, errors in data structures, performance error and
initialization and termination error. Here all the input data must match the data type to
become a valid entry.

6.2.3 Unit Testing:

Unit testing is essentially for the verification of the code produced during the coding phase
and the goal is to test the internal logic of the module program. In the Genetic code project,
the unit

22
testing is done during the coding phase of data entry forms whether the functions are working
properly or not. In this phase all the drivers are tested whether they are rightly connected or
not.

6.2.4 Integration Testing:

All the tested modules are combined into sub systems, which are thentested. The goal is to
see if the modules are properly integrated, and the emphasis being on the testing interfaces
between the modules. In the genetic code integration testing is done mainly on table creation
modules and insertion modules.

6.2.5 Validation Testing :

This testing concentrates on confirming that the software is error-free in all respects. All the
specified validations are verified and the software is subjected to hard core testing. It also
aims at determining the degree of deviation that exists in the software designed from the
specification, they are listed out and are corrected

6.2.6 System Testing:

This testing is a series of different tests whose primary is to fully exercise the computer-based
system. This involves:

Implementing the system in a simulated production environment and testing it.

Introducing errors and testing for error handling.

23
6.3 TEST CASES

How can we test a full Snake game and, assuming it passes that stage, how can we playtest
that? The functional requirements that we developed turn, almost immediately.

To display the snake, the first thing we want to do is to make sure that we can draw the snake
and move it around on the screen. So our testing for correct function will be

1. Can I display the snake's head on the screen?

2. Will it move around as I want it to using keyboard control?

3. Is it displaying correctly?

4. Is the body moving correctly?

5. If we identify an error in the snake, because it's a Class, we will go into the Snake class and
fix it there. However, because we've written the Food and Scoreboard as separate classes,
whatever we do in the Snake class shouldn't break anything in there, unless we accidentally
change the code without noticing.

6. The next step for the snake will be checking what happens when the head is detected as
colliding with something. Does it grow when it eats cat food? Does it die when it hits a wall
or itself! We'd then continue to test the program until we've tested all of the individual
elements and their interactions together.

7. One useful test case is to see if everything is being drawn where you expect. Because we
aren't.

8. Using all the screen, it's possible to draw the food or the snake so that it overlaps the black
rectangle that's the boundary. Has the programmer put the correct limits on the ranges where
the snake and the food can appear?

9. Testing the non-functional requirements often falls into the realm of playability

24
CHAPTER 7

CONTRIBUTION OF THE PROJECT FOR


THE SOCIETY

• Snake is a classic game that requires players to assess their surroundings and find the
quickest or safest route to a point. This is an excellent opportunity to learn about spatial
awareness and plan ahead to your next move.

• The classic game is infamous for using your own success against you when you become so
long that you get in your own way. Whilst many games and activities can teach your child
about vital life skills, there are not many that would educate on long term strategic planning.

• As many parents will know, it can be extremely frustrating to reach such. a high level and
then lose as you crash into your own tail. The game requires patience in order to grow and a
cool head once you inevitably lose. These are all valuable skills to learn early on in a child's
life that will benefit them in later years.

Snake is a tool that can be used as an educational helping hand. One of the important parts of
learning is that you will never get something right the first time. Snake teaches children that
practice makes perfect when it comes to learning new skills,

25
CHAPTER 8

CODE EXPLANATION

 If you press any other key, the program will continue to run as normal.

 The code starts by checking to see if the player has pressed two keys at the same time.
If they have, the code changes the direction of the snake.

 Next, the code checks to see if either key was pressed in a different direction than
expected. If it was, then the code adjusts the position of the snake accordingly.
Finally, it updates how big the snake’s body is getting.

 The code will check if the two keys being pressed at the same time are either ‘UP’ or
‘DOWN’. If they are, then the direction of the snake will be changed accordingly.

 If the two keys being pressed are not equal, then the code will check to see if they are
different directions. If they are not, then the snake’s position will be adjusted by 10
pixels in each direction. Lastly, a function is created that will change how big the
snake’s body grows when it moves.

 The code starts by creating a list of snake positions. The first position in the list is at
(0, 0), and the last position in the list is at (window_x-10, window_y-10).

 Next, the code checks to see if any of the positions in the snake are equal to a fruit
position. If so, then that fruit gets scored 10 points and is added to the fruit spawn
variable. If no fruits are found, then the game moves on to checking for collisions
between snakes and fruits.

 If two snakes intersect, then their scores are incremented by 10. If a snake collides
with a wall or another snake, then that snake dies and game over conditions are
triggered. Finally, touching any part of a snake causes it to die and also triggers game
over conditions.

26
 The code will check to see if two positions in the snake body are equal. If they are,
then the score is incremented by 10 and the game_over() function is called.

 If a player touches the snake body at any point, then the game_over() function will be
calle

27
OUTPUT

28
CHAPTER 9

CONCLUSION

The project in python programming of Snake Game is a simple console application with very
simple graphics. In this project, you can play the popular "Snake Game" just like you played
it elsewhere. You have to use the up, down, right, or left arrows to move the snake.

Foods are provided at the several coordinates of the screen for the snake to eat. Every time
the snake eats the food. its length will be increased by one element along with the score. It
isn't the world's greatest game, but it does give you an idea of what you can achieve with
relatively simple python programming, and perhaps the basis by which to extend the
principles and create more interesting games on your own.

LIMITATIONS:

• The existing system only provides a text-based interface, which is not as user-friendly as
Graphical user Interface.

• Since the system is implemented in Manual, the response is very slow.

• The transactions are executed in off-line mode, hence on-line data capture and modification
is not possible.

29
FUTURE SCOPE:

In this project, I have used a simple application. This project will be able to be implemented
in future after making some changes and modifications as I made this project at a low level.
The modifications that can be done in this project are:

1. It can be made with good graphics,

2. We can add more options like Top scores and Player Profile,

3. We can add multiplayer option

30
REFERENCES

 Tieturi, February 1985. ISSN 0780-9778 Gerard Goggin (2010), Global Mobile Media,
Taylor & Francis, p. 101, ISBN 978-0-415-46917-3, retrieved April 7, 2011

 Rusel DeMaria & Johnny L. Wilson (2003). High score!: the illustrated history of
electronic games (2 ed.). McGraw-Hill Professional. p. 24. ISBN 0-07-223172-6.
Retrieved April 7, 2011.

 "Blockade video game, Gremlin Ind, inc. (1976)". Arcade-history.com. April 4, 2008.
Archived from the original on June 11, 2011. Retrieved November 4, 2011.

 Blockade at the Killer List of Videogames Rusel DeMaria & Johnny L. Wilson (2003).
High score!: the illustrated history of electronic games (2 ed.)

 McGraw-Hill Professional. p. 48. ISBN 0-07-223172-6."Retrogaming Times Monthly


7". My.stratos.net. January 1, 2005. Archived from the original on September 22, 2011.
Retrieved November 4, 2011.

 More, James (January 20, 2009). "History of Nokia part 2: Snake | Nokia Conversations
- The official Nokia Blog". Conversations.nokia.com. Archived from the original on
July 23, 2011. Retrieved November 4, 2011.

 "Taneli Armanto: Snake Creator Receives Special Recognition". Dexigner. Archived


from the original on 2 October 2017. Retrieved 6 March 2013.

 neoncherry (August 12, 2007). "The Unofficial Nokia Gaming Blog: Snakes for S60
Download". Archived from the original on November 1, 2007. Retrieved November 4,
2011

31

You might also like