import pygame
from direction import Direction

class Snake(pygame.sprite.Sprite):
    def __init__(self):
        super(Snake, self).__init__()
        self.Image = pygame.image.load("images/head.png")
        self.Rotate = pygame.transform.rotate(self.Image, 0)
        self.rect = self.Rotate.get_rect(x = 400-16, y = 304-16)
        self.direction = Direction.UP
        
    def change_direction(self, new_direction):
        self.direction = new_direction

    def UPdate(self):
        self.Rotate = pygame.transform.rotate(self.Image, self.direction.value*90)

        if self.direction == Direction.UP:
            self.rect.move_ip(0,-32)
        if self.direction == Direction.RIGHT:
            self.rect.move_ip(32,0)
        if self.direction == Direction.DOWN:
            self.rect.move_ip(0,32)
        if self.direction == Direction.LEFT:
            self.rect.move_ip(-32,0)
