Professional Documents
Culture Documents
By “Samyak Oswal”
Acknowledgement
- Samyak Oswal
Index:
● Hardware specification
● Software specification
● Project objective
● Project usage
● Project outline
● Flow chart
● Program specifications
● Source code
● Output
● References
Hardware Specifications:
This project was made on the system with the following
Configuration:
-intel i3 8th gen processor or higher
-windows 7 or higher
-Software Specification:
The following are the software specifications of the program:
Pycharm
Spyder
Pygame module
Project Objective:
Try your hardest to survive and thrive by eating fruits, which in turn makes you grow in size!
Project usage:
This project helps the player improve their hand-eye coordination
PROJECT OUTLINE
The snake game, is a game which requires your attention,control and time. The snake
will be controlled by the player using the arrow-keys. The game has a highly
competitive background and can be enjoyed amongst the comforts of friends. The
challenge is to attain the highest score. After one player does their best, the other can
take over to either beat it, or die trying.
The whole code is based on easy steps starting with installing pygame, creating the
screen, snake, defining movement of the snake, defining game over criterias, adding the
food for the snake to grow, growth of the snake itself and at last displaying the score
which everyone loves to show-off about.
SOURCE CODE:
import pygame # display settings
# color codes
# initialize screen
white = (255, 255, 255)
screen = pygame.display.set_mode((dis_width,
yellow = (255, 255, 102) dis_height))
game_over = False
game_close = False
# game settings
snake_block = 10 x1 = dis_width / 2
snake_speed = 15 y1 = dis_height / 2
x1_change = 0
font_style = pygame.font.SysFont("bahnschrift", 25)
y1_change = 0
score_font = pygame.font.SysFont("comicsansms",
35)
snake_List = []
snake_length = 1
food_x = round(random.randrange(0, dis_width - for event in pygame.event.get():
snake_block) / 10.0) * 10.0
if event.type == pygame.KEYDOWN:
food_y = round(random.randrange(0, dis_height
- snake_block) / 10.0) * 10.0 if event.key == pygame.K_q:
game_over = True
while not game_over:
game_close = False
if event.key == pygame.K_c:
while game_close:
gameLoop()
screen.fill(blue)
for event in pygame.event.get():
message("You Lost! Press 'C' to Play Again
or 'Q' to Quit", red)
if event.type == pygame.QUIT:
score_self(snake_length - 1)
game_over = True
pygame.display.update()
if event.type == pygame.KEYDOWN: if x1 >= dis_width or x1 < 0 or y1 >= dis_height or y1 < 0:
if event.key == pygame.K_LEFT:
game_close = True
x1_change = -snake_block
x1 += x1_change
y1_change = 0
y1 += y1_change
elif event.key == pygame.K_RIGHT:
x1_change = snake_block
screen.fill(blue)
y1_change = -snake_block
snake_Head = [x1, y1]
x1_change = 0 snake_List.append(snake_Head)
clock.tick(snake_speed)
pygame.display.update()
pygame.quit()
quit()
def score_self(score): 3])
value = score_font.render("Your Score: " +
str(score), True, yellow) # Main function call
https://www.pygame.org/news