import pygame
import random

pygame.init()


white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, 255, 0)


dis = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()
run = True
while run:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False;
    dis.fill(white)
    pygame.display.flip()
pygame.quit()


snake_block = 10
snake_speed = 15
clock = pygame.time.Clock()


class Snake(pygame.sprite.Sprite):
    def __init__(self):
        super().__init__()
        self.image = pygame.Surface((snake_block, snake_block))
        self.image.fill(black)
        self.rect = self.image.get_rect()
        self.rect.x = 400
        self.rect.y = 300
        self.dx = 0
        self.dx = 0
        self.body = []
        self.length = 1
        self.score = 0


    def update(self):
        self.rect.x += self.dx
        self.rect.y += self.dy



        self.body.append([self.rect.x, self.rect.y])
        if len(self.body) > self.length:
            del self.body[0]



        for segment  in self.body[:-1]:
            if segment[0] == self.rect.x and segment[1] == self.rect.y:
                return True
            return False

    def draw_body(self, surface):
        for segment in self.body[:-1]:
            pygame.draw.rect(surface, black, [segment[0], [segment[1], snake_block, snake_block])

