SlideShare a Scribd company logo
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 Flow Chart
Snake Game Flow ChartSnake Game Flow Chart
Snake Game Flow ChartMuhammad Aziz
 
Final project report of a game
Final project report of a gameFinal project report of a game
Final project report of a gameNadia Nahar
 
Tic tac toe game with graphics presentation
Tic  tac  toe game with graphics presentationTic  tac  toe game with graphics presentation
Tic tac toe game with graphics presentationPrionto Abdullah
 
Car racing game for android
Car racing game for androidCar racing game for android
Car racing game for androidravijot singh
 
Final year project presentation
Final year project presentationFinal year project presentation
Final year project presentationSulemanAliMalik
 
Gaming Documentation final
Gaming Documentation finalGaming Documentation final
Gaming Documentation finalMemesTech
 
Car Game - Final Year Project
Car Game - Final Year ProjectCar Game - Final Year Project
Car Game - Final Year ProjectVivek Naskar
 
Design phase of game development of unity 2d game
Design phase of game development of unity 2d game Design phase of game development of unity 2d game
Design phase of game development of unity 2d game Muhammad Maaz Irfan
 
game project presentation
game project presentationgame project presentation
game project presentationKavi Kumar
 
Android Application And Unity3D Game Documentation
Android Application And Unity3D Game DocumentationAndroid Application And Unity3D Game Documentation
Android Application And Unity3D Game DocumentationSneh Raval
 
Python games
Python gamesPython games
Python gamesmolw
 
Project report 393_395
Project report 393_395Project report 393_395
Project report 393_395VishruthKhare
 
Smart Home Automation using Voice Assistant
Smart Home Automation using Voice AssistantSmart Home Automation using Voice Assistant
Smart Home Automation using Voice AssistantTezpur University
 
Final year project presentation in android application
Final year project presentation in android applicationFinal year project presentation in android application
Final year project presentation in android applicationChirag Thaker
 

What's hot (20)

Snake PY Game.pptx
Snake PY Game.pptxSnake PY Game.pptx
Snake PY Game.pptx
 
Snake Game Flow Chart
Snake Game Flow ChartSnake Game Flow Chart
Snake Game Flow Chart
 
Final project report of a game
Final project report of a gameFinal project report of a game
Final project report of a game
 
Tic tac toe game with graphics presentation
Tic  tac  toe game with graphics presentationTic  tac  toe game with graphics presentation
Tic tac toe game with graphics presentation
 
Car racing game for android
Car racing game for androidCar racing game for android
Car racing game for android
 
Final year project presentation
Final year project presentationFinal year project presentation
Final year project presentation
 
Gaming Documentation final
Gaming Documentation finalGaming Documentation final
Gaming Documentation final
 
Car Game - Final Year Project
Car Game - Final Year ProjectCar Game - Final Year Project
Car Game - Final Year Project
 
Design phase of game development of unity 2d game
Design phase of game development of unity 2d game Design phase of game development of unity 2d game
Design phase of game development of unity 2d game
 
Tic tac toe
Tic tac toeTic tac toe
Tic tac toe
 
game project presentation
game project presentationgame project presentation
game project presentation
 
Android Application And Unity3D Game Documentation
Android Application And Unity3D Game DocumentationAndroid Application And Unity3D Game Documentation
Android Application And Unity3D Game Documentation
 
MUSIC PLAYER.pptx
MUSIC PLAYER.pptxMUSIC PLAYER.pptx
MUSIC PLAYER.pptx
 
Python games
Python gamesPython games
Python games
 
E-ball Technology ppt
E-ball Technology pptE-ball Technology ppt
E-ball Technology ppt
 
Project report 393_395
Project report 393_395Project report 393_395
Project report 393_395
 
Mini Project PPT
Mini Project PPTMini Project PPT
Mini Project PPT
 
Smart Home Automation using Voice Assistant
Smart Home Automation using Voice AssistantSmart Home Automation using Voice Assistant
Smart Home Automation using Voice Assistant
 
Zombi - Shoot for Survive
Zombi - Shoot for SurviveZombi - Shoot for Survive
Zombi - Shoot for Survive
 
Final year project presentation in android application
Final year project presentation in android applicationFinal year project presentation in android application
Final year project presentation in android application
 

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
 
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
 
Portfolio
PortfolioPortfolio
Portfolio
 

Recently uploaded

Electrical shop management system project report.pdf
Electrical shop management system project report.pdfElectrical shop management system project report.pdf
Electrical shop management system project report.pdfKamal Acharya
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单
一比一原版(UofT毕业证)多伦多大学毕业证成绩单一比一原版(UofT毕业证)多伦多大学毕业证成绩单
一比一原版(UofT毕业证)多伦多大学毕业证成绩单tuuww
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.PrashantGoswami42
 
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdfONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdfKamal Acharya
 
retail automation billing system ppt.pptx
retail automation billing system ppt.pptxretail automation billing system ppt.pptx
retail automation billing system ppt.pptxfaamieahmd
 
Lect 2 - Design of slender column-2.pptx
Lect 2 - Design of slender column-2.pptxLect 2 - Design of slender column-2.pptx
Lect 2 - Design of slender column-2.pptxHamzaKhawar4
 
Paint shop management system project report.pdf
Paint shop management system project report.pdfPaint shop management system project report.pdf
Paint shop management system project report.pdfKamal Acharya
 
Supermarket billing system project report..pdf
Supermarket billing system project report..pdfSupermarket billing system project report..pdf
Supermarket billing system project report..pdfKamal Acharya
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfKamal Acharya
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopEmre Günaydın
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edgePaco Orozco
 
Attraction and Repulsion type Moving Iron Instruments.pptx
Attraction and Repulsion type Moving Iron Instruments.pptxAttraction and Repulsion type Moving Iron Instruments.pptx
Attraction and Repulsion type Moving Iron Instruments.pptxkarthikeyanS725446
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.MdManikurRahman
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdfKamal Acharya
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectRased Khan
 
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单tuuww
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationDr. Radhey Shyam
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdfKamal Acharya
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdfKamal Acharya
 
1. Henrich Triangle Safety and Fire Presentation
1. Henrich Triangle Safety and Fire Presentation1. Henrich Triangle Safety and Fire Presentation
1. Henrich Triangle Safety and Fire PresentationBhuwanAgrawal8
 

Recently uploaded (20)

Electrical shop management system project report.pdf
Electrical shop management system project report.pdfElectrical shop management system project report.pdf
Electrical shop management system project report.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单
一比一原版(UofT毕业证)多伦多大学毕业证成绩单一比一原版(UofT毕业证)多伦多大学毕业证成绩单
一比一原版(UofT毕业证)多伦多大学毕业证成绩单
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdfONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
ONLINE CAR SERVICING SYSTEM PROJECT REPORT.pdf
 
retail automation billing system ppt.pptx
retail automation billing system ppt.pptxretail automation billing system ppt.pptx
retail automation billing system ppt.pptx
 
Lect 2 - Design of slender column-2.pptx
Lect 2 - Design of slender column-2.pptxLect 2 - Design of slender column-2.pptx
Lect 2 - Design of slender column-2.pptx
 
Paint shop management system project report.pdf
Paint shop management system project report.pdfPaint shop management system project report.pdf
Paint shop management system project report.pdf
 
Supermarket billing system project report..pdf
Supermarket billing system project report..pdfSupermarket billing system project report..pdf
Supermarket billing system project report..pdf
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
Attraction and Repulsion type Moving Iron Instruments.pptx
Attraction and Repulsion type Moving Iron Instruments.pptxAttraction and Repulsion type Moving Iron Instruments.pptx
Attraction and Repulsion type Moving Iron Instruments.pptx
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdf
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
一比一原版(UNK毕业证)内布拉斯加州立大学科尼分校毕业证成绩单
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
Furniture showroom management system project.pdf
Furniture showroom management system project.pdfFurniture showroom management system project.pdf
Furniture showroom management system project.pdf
 
1. Henrich Triangle Safety and Fire Presentation
1. Henrich Triangle Safety and Fire Presentation1. Henrich Triangle Safety and Fire Presentation
1. Henrich Triangle Safety and Fire Presentation
 

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.