I wanted to create a snake game program using python/pygame because I grew up playing snake on my Nokia phone and I wanted to not only test my ability in coding python but also refreshing myself with pygame since I had not created a program with it in a long time. Some of my friends were also quite interested if I would be able to create the game and to try playing it when I was finished. My program would be designed almost identical to the generic snake games you can find online. It would consist of the player controlled snake, the map of which it roams about, the food that is spawned in and the score counter. The basis of the game is that the player would use their arrow keys to change the direction of the snake where their goal would be to collect the highest amount of food which in turn would increase their score count as well as making the snake longer and move faster so that it’s more difficult to control. If for any reason the head of the snake touches any portion of its own body, the game will then reset.
Basic plan of code:
import pygame
import sys
import time
import random
screen_width, screen_height = 320, 240
pygame.time.clock()
class Snake(object):
def lose(self):
def move(self):
class Apple(object):
def randomize(self):
def check_eat(snake,apple)
Code link: https://docs.google.com/document/d/1bmr6Xvq5_cWLmHK-M5UYHPH8IzcYDIit3zkZZ2qb9JE/edit
Overall I think I was pretty successful in completing the goals that I set out at the beginning of the project. I was able to create a functional snake game that I can play with my friends from scratch using my skills in python. Some problems that I ran into throughout this project was during the coding portion of the project because I wasn’t super familiar with pycharm so I had to read a lot of documents and articles of how to use the commands.