New Text Document
New Text Document
import random
# Initialize pygame
pygame.init()
# Define colors
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
BLACK = (0, 0, 0)
RED = (213, 50, 80)
BLUE = (50, 153, 213)
YELLOW = (255, 255, 102)
# Snake movement
x1_change = 0
y1_change = 0
# Snake body
snake_List = []
Length_of_snake = 1
# Initial food position
foodx = round(random.randrange(0, WIDTH - SNAKE_SIZE) / 10.0) * 10.0
foody = round(random.randrange(0, HEIGHT - SNAKE_SIZE) / 10.0) * 10.0
# Game clock
clock = pygame.time.Clock()
while game_close:
screen.fill(BLUE)
message("You Lost! Press Q-Quit or C-Play Again", RED)
Your_score(Length_of_snake - 1)
pygame.display.update()
x1 += x1_change
y1 += y1_change
screen.fill(BLUE)
# Draw food
pygame.draw.rect(screen, YELLOW, [foodx, foody, SNAKE_SIZE, SNAKE_SIZE])
pygame.display.update()
pygame.quit()
quit()