SlideShare a Scribd company logo
1 of 6
Download to read offline
MuhammadAziz
FINAL PROJECT
REPORT
Department of Computer System Engineering
Universityof Engineering & Technology Peshawar
FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 1
Final Project Report Overall Status: Complete
Project Name: Snake Game in Python
1/2/2019
Snake Game:
Snake is a game where its body grows in length. There is no standard version of
the game. The concept originated in the 1976 arcade game Blockade, and its simplicity
has led to many implementations (some of which have the word snake or worm in the
title). After a variant was preloaded on Nokia mobile phones in 1998, there was a
resurgence of interest in the Snake concept as it found a larger audience.
Figure 1-Snake–Thefirstpublished byNokia,for monochromephones.Itwasprogrammedin1997byTaneliArmantoof
Nokia and introduced ontheNokia 6110.
Py-Game
Pygame is a cross-platform set of
Pythonmodules designed for
writing video games. It includes
computer graphicsand sound
libraries designed to beused with
thePythonprogramming
language.
Pythonis an interpreted,high-level,general-purpose programming
language. Created by Guido van Rossum and first released in 1991,
Pythonhas a design philosophythat emphasizescodereadability,
notablyusing significant whitespace.It provides constructs that
enable clear programming on both small and large scales.
Game Algorithm: All movement rating functionsand evolutionary algorithm-based optimization. Abstract:Snake
game is a computeraction game; whosegoal is to controla snake to move andcollect foodin a map.
FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 2
Summery  Using Object Oriented Programing Language to approach the game implementation.
 Adding Colors and visual view tothe gaming window.
 Snake is the common name for a video game concept where the player maneuvers a line whichgrows in
length, withthe line itself being a primary obstacle.
Flow Chart  The flow chart of game is givenin below fig.
Mainfunction  Snake game is a computer action game, whose goal is to control a snake to move and collect food in a
map. Inthis game we developa controller based on movement rating functions considering smoothness,
space, and food
 This simply imports the maingame class that we’ll create momentarily, makes a new instance, and calls
the game.
FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 3
Snake Movement  We will once againutilize PyGame’s event handlers, this time to respond to the arrow keys toguide our
snake. Inside the Game.py file, add the followingbefore our game loop inside the loop () function.
Game Area  The Whole game window is set to 500pixels.
 There are rows and columns in early console
 Later all the game window is modified toPlane display of multi-colors.
Colliding withthe Wall  Let’s think talk this. Soour original window, assumingyou have kept the same settings, is 500 x500, but there
is now a 35 pixel border on all four edges, effectively reducing our play area to 440 x440. Sothese will be the
dimensions we need to check for.
Creating food  Our snake can’t grow without having a steady supply of apples to eat. Let’s breakdown the requirements for
our apple.
 We will needan X and Y position at which to draw the apple
 A randomize function that will generate random coordinates on the playable game area as needed
 A draw function to display the apple
Eating Food  We will be utilizing the build in collisiondetection for PyGame rectangles to determine whenan
apple has been eaten. We need to revise a few pieces of code to make this happen.
Increasing Size of Snake  The system we are going to use to keeptrack of the various body segments of the snake is going to
work by storing the last position of the head in anarray, pushing to the top, each time the move
method of Snake is called.
Snake Colliding
withItself
 Tocheck if we have collided withourselves, we do a cut and dry check where we iterate over each
body element and see if it has the same X and Y coordinate positions of the head.
 If so, this causes an error and restarts the game. This alsoworks for trying to move the snake
backwards.
Conclusion  Our basic snake game is now playable and I hope you feel a lot more comfortable withPyGame and
game programming then youdid before youread this article.
Colors, Config, and Magic
Numbers
 In game programming, it can be very easy for our code to begin to lose clarity. There are often
shapes or sprites being drawn at arbitrary X and Y coordinates, and those sprites often have
movement, colors, and animations. Next thing you know, you’ve got magicnumbers and repeated
values spread out everywhere.
Initialization and the Game
Loop
 Now that we know everything is working successfully sofar, let’s next add the code to bootstrap
PyGame and start our game loop. Let’s first add a bit of code to give our window a size and a title.
Issues  Installing IDE
 Implementation 1st time
 Adding graphics and level togame
FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 4
Movement toward food
UpwardMotion
Movement only at Positive Y-axis
Figure2-Up
LeftwardMotion
Movement only at negative X-axis
Figure3-Left
Downward Motion
Movement at Negative Y-axis
Figure4-Down
Rightward Motion
Movement only at positive X-axis
Figure5-Right
FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 5
Figure8-Level 3
Snake Bodyenlargement
Aftereating mean getting the foodthe length ofsnake increases.
Level 1 Snake length
Figure6-Level 1
Level 2
Figure7-Level 2
Level 3
The end.

More Related Content

What's hot

Snake game powerpoint presentation by rohit malav
Snake game powerpoint presentation by rohit malavSnake game powerpoint presentation by rohit malav
Snake game powerpoint presentation by rohit malavRohit malav
 
report on snake game
report on snake game report on snake game
report on snake game azhar niaz
 
Car Game - Final Year Project
Car Game - Final Year ProjectCar Game - Final Year Project
Car Game - Final Year ProjectVivek Naskar
 
Android Application And Unity3D Game Documentation
Android Application And Unity3D Game DocumentationAndroid Application And Unity3D Game Documentation
Android Application And Unity3D Game DocumentationSneh Raval
 
Report on car racing game for android
Report on car racing game for androidReport on car racing game for android
Report on car racing game for androidravijot singh
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentationSaad Symbian
 
COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTvineet raj
 
The complete srs documentation of our developed game.
The complete srs documentation of our developed game. The complete srs documentation of our developed game.
The complete srs documentation of our developed game. Isfand yar Khan
 
Software Engineer- A unity 3d Game
Software Engineer- A unity 3d GameSoftware Engineer- A unity 3d Game
Software Engineer- A unity 3d GameIsfand yar Khan
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programingKrishna Agarwal
 
Snake Game Flow Chart
Snake Game Flow ChartSnake Game Flow Chart
Snake Game Flow ChartMuhammad Aziz
 
Project report 393_395
Project report 393_395Project report 393_395
Project report 393_395VishruthKhare
 
Final year project presentation
Final year project presentationFinal year project presentation
Final year project presentationSulemanAliMalik
 
Game Development Step by Step
Game Development Step by StepGame Development Step by Step
Game Development Step by StepBayu Sembada
 
Car racing game for android
Car racing game for androidCar racing game for android
Car racing game for androidravijot singh
 
Final Year Game Project Presentation
Final Year Game Project Presentation Final Year Game Project Presentation
Final Year Game Project Presentation Nusrat Jahan Shanta
 
MIND GAME ZONE - Abhijeet
MIND GAME ZONE - AbhijeetMIND GAME ZONE - Abhijeet
MIND GAME ZONE - AbhijeetAbhijeet Kalsi
 
Mobile Game Development in Unity
Mobile Game Development in UnityMobile Game Development in Unity
Mobile Game Development in UnityHakan Saglam
 

What's hot (20)

Snake game powerpoint presentation by rohit malav
Snake game powerpoint presentation by rohit malavSnake game powerpoint presentation by rohit malav
Snake game powerpoint presentation by rohit malav
 
report on snake game
report on snake game report on snake game
report on snake game
 
Car Game - Final Year Project
Car Game - Final Year ProjectCar Game - Final Year Project
Car Game - Final Year Project
 
Snake Game Report
Snake Game ReportSnake Game Report
Snake Game Report
 
Android Application And Unity3D Game Documentation
Android Application And Unity3D Game DocumentationAndroid Application And Unity3D Game Documentation
Android Application And Unity3D Game Documentation
 
Report on car racing game for android
Report on car racing game for androidReport on car racing game for android
Report on car racing game for android
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentation
 
COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORT
 
The complete srs documentation of our developed game.
The complete srs documentation of our developed game. The complete srs documentation of our developed game.
The complete srs documentation of our developed game.
 
Software Engineer- A unity 3d Game
Software Engineer- A unity 3d GameSoftware Engineer- A unity 3d Game
Software Engineer- A unity 3d Game
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
 
Snake Game Flow Chart
Snake Game Flow ChartSnake Game Flow Chart
Snake Game Flow Chart
 
Project report 393_395
Project report 393_395Project report 393_395
Project report 393_395
 
Final year project presentation
Final year project presentationFinal year project presentation
Final year project presentation
 
Game Development Step by Step
Game Development Step by StepGame Development Step by Step
Game Development Step by Step
 
Car racing game for android
Car racing game for androidCar racing game for android
Car racing game for android
 
Flappy Bird Tutorial
Flappy Bird TutorialFlappy Bird Tutorial
Flappy Bird Tutorial
 
Final Year Game Project Presentation
Final Year Game Project Presentation Final Year Game Project Presentation
Final Year Game Project Presentation
 
MIND GAME ZONE - Abhijeet
MIND GAME ZONE - AbhijeetMIND GAME ZONE - Abhijeet
MIND GAME ZONE - Abhijeet
 
Mobile Game Development in Unity
Mobile Game Development in UnityMobile Game Development in Unity
Mobile Game Development in Unity
 

Similar to Final project report Snake Game in Python

Presentation OF Manisha gupta mam 2.pptx
Presentation OF Manisha gupta mam 2.pptxPresentation OF Manisha gupta mam 2.pptx
Presentation OF Manisha gupta mam 2.pptxvipin523447
 
PPT of Flappy Bird Game for final year.pptx
PPT of Flappy Bird Game for final year.pptxPPT of Flappy Bird Game for final year.pptx
PPT of Flappy Bird Game for final year.pptxtaxihig737
 
6 surprising ways_to_use_jupyter_0
6 surprising ways_to_use_jupyter_06 surprising ways_to_use_jupyter_0
6 surprising ways_to_use_jupyter_0Weghlis Azzariou
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA GameSohil Gupta
 
PowerPoint Presentation For Snake Game Project In Java
PowerPoint Presentation For Snake Game Project In JavaPowerPoint Presentation For Snake Game Project In Java
PowerPoint Presentation For Snake Game Project In JavaShrikala4
 
Y1 gd level_designworkflow
Y1 gd level_designworkflowY1 gd level_designworkflow
Y1 gd level_designworkflownazaryth98
 
Y1 gd level_designworkflow
Y1 gd level_designworkflowY1 gd level_designworkflow
Y1 gd level_designworkflownazaryth98
 
Pac Man: Game Development using PDA and OOP
Pac Man: Game Development using PDA and OOPPac Man: Game Development using PDA and OOP
Pac Man: Game Development using PDA and OOPIRJET Journal
 
Angry birds
Angry birdsAngry birds
Angry birdsmrsloan
 
Game Development With Python and Pygame
Game Development With Python and PygameGame Development With Python and Pygame
Game Development With Python and PygameChariza Pladin
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196Mahmoud Samir Fayed
 
Most asked JAVA Interview Questions & Answers.
Most asked JAVA Interview Questions & Answers.Most asked JAVA Interview Questions & Answers.
Most asked JAVA Interview Questions & Answers.Questpond
 
AbadIA: the abbey of the crime AI - GDG Cloud London 2018
AbadIA:  the abbey of the crime AI - GDG Cloud London 2018AbadIA:  the abbey of the crime AI - GDG Cloud London 2018
AbadIA: the abbey of the crime AI - GDG Cloud London 2018Juantomás García Molina
 
Run and jump tutorial (part 2) scenes
Run and jump tutorial (part 2)   scenesRun and jump tutorial (part 2)   scenes
Run and jump tutorial (part 2) scenesMuhd Basheer
 

Similar to Final project report Snake Game in Python (20)

Presentation OF Manisha gupta mam 2.pptx
Presentation OF Manisha gupta mam 2.pptxPresentation OF Manisha gupta mam 2.pptx
Presentation OF Manisha gupta mam 2.pptx
 
PPT of Flappy Bird Game for final year.pptx
PPT of Flappy Bird Game for final year.pptxPPT of Flappy Bird Game for final year.pptx
PPT of Flappy Bird Game for final year.pptx
 
6 surprising ways_to_use_jupyter_0
6 surprising ways_to_use_jupyter_06 surprising ways_to_use_jupyter_0
6 surprising ways_to_use_jupyter_0
 
intern.pdf
intern.pdfintern.pdf
intern.pdf
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA Game
 
CS Research Poster 2014
CS Research Poster 2014CS Research Poster 2014
CS Research Poster 2014
 
Project list
Project listProject list
Project list
 
Python lecture 10
Python lecture 10Python lecture 10
Python lecture 10
 
PowerPoint Presentation For Snake Game Project In Java
PowerPoint Presentation For Snake Game Project In JavaPowerPoint Presentation For Snake Game Project In Java
PowerPoint Presentation For Snake Game Project In Java
 
Y1 gd level_designworkflow
Y1 gd level_designworkflowY1 gd level_designworkflow
Y1 gd level_designworkflow
 
Street runner final
Street runner finalStreet runner final
Street runner final
 
Y1 gd level_designworkflow
Y1 gd level_designworkflowY1 gd level_designworkflow
Y1 gd level_designworkflow
 
Pac Man: Game Development using PDA and OOP
Pac Man: Game Development using PDA and OOPPac Man: Game Development using PDA and OOP
Pac Man: Game Development using PDA and OOP
 
Angry birds
Angry birdsAngry birds
Angry birds
 
Game Development With Python and Pygame
Game Development With Python and PygameGame Development With Python and Pygame
Game Development With Python and Pygame
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
 
A mazing Game
A mazing GameA mazing Game
A mazing Game
 
Most asked JAVA Interview Questions & Answers.
Most asked JAVA Interview Questions & Answers.Most asked JAVA Interview Questions & Answers.
Most asked JAVA Interview Questions & Answers.
 
AbadIA: the abbey of the crime AI - GDG Cloud London 2018
AbadIA:  the abbey of the crime AI - GDG Cloud London 2018AbadIA:  the abbey of the crime AI - GDG Cloud London 2018
AbadIA: the abbey of the crime AI - GDG Cloud London 2018
 
Run and jump tutorial (part 2) scenes
Run and jump tutorial (part 2)   scenesRun and jump tutorial (part 2)   scenes
Run and jump tutorial (part 2) scenes
 

Recently uploaded

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 

Recently uploaded (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 

Final project report Snake Game in Python

  • 1. MuhammadAziz FINAL PROJECT REPORT Department of Computer System Engineering Universityof Engineering & Technology Peshawar
  • 2. FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 1 Final Project Report Overall Status: Complete Project Name: Snake Game in Python 1/2/2019 Snake Game: Snake is a game where its body grows in length. There is no standard version of the game. The concept originated in the 1976 arcade game Blockade, and its simplicity has led to many implementations (some of which have the word snake or worm in the title). After a variant was preloaded on Nokia mobile phones in 1998, there was a resurgence of interest in the Snake concept as it found a larger audience. Figure 1-Snake–Thefirstpublished byNokia,for monochromephones.Itwasprogrammedin1997byTaneliArmantoof Nokia and introduced ontheNokia 6110. Py-Game Pygame is a cross-platform set of Pythonmodules designed for writing video games. It includes computer graphicsand sound libraries designed to beused with thePythonprogramming language. Pythonis an interpreted,high-level,general-purpose programming language. Created by Guido van Rossum and first released in 1991, Pythonhas a design philosophythat emphasizescodereadability, notablyusing significant whitespace.It provides constructs that enable clear programming on both small and large scales. Game Algorithm: All movement rating functionsand evolutionary algorithm-based optimization. Abstract:Snake game is a computeraction game; whosegoal is to controla snake to move andcollect foodin a map.
  • 3. FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 2 Summery  Using Object Oriented Programing Language to approach the game implementation.  Adding Colors and visual view tothe gaming window.  Snake is the common name for a video game concept where the player maneuvers a line whichgrows in length, withthe line itself being a primary obstacle. Flow Chart  The flow chart of game is givenin below fig. Mainfunction  Snake game is a computer action game, whose goal is to control a snake to move and collect food in a map. Inthis game we developa controller based on movement rating functions considering smoothness, space, and food  This simply imports the maingame class that we’ll create momentarily, makes a new instance, and calls the game.
  • 4. FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 3 Snake Movement  We will once againutilize PyGame’s event handlers, this time to respond to the arrow keys toguide our snake. Inside the Game.py file, add the followingbefore our game loop inside the loop () function. Game Area  The Whole game window is set to 500pixels.  There are rows and columns in early console  Later all the game window is modified toPlane display of multi-colors. Colliding withthe Wall  Let’s think talk this. Soour original window, assumingyou have kept the same settings, is 500 x500, but there is now a 35 pixel border on all four edges, effectively reducing our play area to 440 x440. Sothese will be the dimensions we need to check for. Creating food  Our snake can’t grow without having a steady supply of apples to eat. Let’s breakdown the requirements for our apple.  We will needan X and Y position at which to draw the apple  A randomize function that will generate random coordinates on the playable game area as needed  A draw function to display the apple Eating Food  We will be utilizing the build in collisiondetection for PyGame rectangles to determine whenan apple has been eaten. We need to revise a few pieces of code to make this happen. Increasing Size of Snake  The system we are going to use to keeptrack of the various body segments of the snake is going to work by storing the last position of the head in anarray, pushing to the top, each time the move method of Snake is called. Snake Colliding withItself  Tocheck if we have collided withourselves, we do a cut and dry check where we iterate over each body element and see if it has the same X and Y coordinate positions of the head.  If so, this causes an error and restarts the game. This alsoworks for trying to move the snake backwards. Conclusion  Our basic snake game is now playable and I hope you feel a lot more comfortable withPyGame and game programming then youdid before youread this article. Colors, Config, and Magic Numbers  In game programming, it can be very easy for our code to begin to lose clarity. There are often shapes or sprites being drawn at arbitrary X and Y coordinates, and those sprites often have movement, colors, and animations. Next thing you know, you’ve got magicnumbers and repeated values spread out everywhere. Initialization and the Game Loop  Now that we know everything is working successfully sofar, let’s next add the code to bootstrap PyGame and start our game loop. Let’s first add a bit of code to give our window a size and a title. Issues  Installing IDE  Implementation 1st time  Adding graphics and level togame
  • 5. FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 4 Movement toward food UpwardMotion Movement only at Positive Y-axis Figure2-Up LeftwardMotion Movement only at negative X-axis Figure3-Left Downward Motion Movement at Negative Y-axis Figure4-Down Rightward Motion Movement only at positive X-axis Figure5-Right
  • 6. FINAL PROGRESS REPORT SNAKE GAME IN PYHTON MUHAMMADAZIZ 5 Figure8-Level 3 Snake Bodyenlargement Aftereating mean getting the foodthe length ofsnake increases. Level 1 Snake length Figure6-Level 1 Level 2 Figure7-Level 2 Level 3 The end.