import pygame
from pygame.constants import SCRAP_SELECTION
from pygame.draw import *

pygame.init()

FPS = 30
screen = pygame.display.set_mode((1280, 720))


def local_cord(x1, scale):
    return int(x1 * scale)



def chuvak(Surface, x, y, scale):

    '''(function) chuvak : (Surface, x0, y0, scale). 
    Function draws man with zero cordinates at the head centre. 
    rect normal size : <- 190, -> 190, v - 510, ^ 50. '''

    #arms
    line(Surface, (0, 0, 0), (x + local_cord(-35, scale), y + local_cord(75, scale)), (x + local_cord(-190, scale), y + local_cord(230, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(35, scale), y + local_cord(75, scale)), (x + local_cord(190, scale), y + local_cord(230, scale)), 1)

    #legs
    line(Surface, (0, 0, 0), (x + local_cord(-40, scale), y + local_cord(350, scale)), (x + local_cord(-100, scale), y + local_cord(500, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(40, scale), y + local_cord(350, scale)), (x + local_cord(100, scale), y + local_cord(500, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(-100, scale), y + local_cord(500, scale)), (x + local_cord(-140, scale), y + local_cord(510, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(100, scale), y + local_cord(500, scale)), (x + local_cord(140, scale), y + local_cord(510, scale)), 1)
    
    #body and head
    ellipse(Surface, (167, 147, 172), (x + local_cord(-75, scale), y + local_cord(30, scale), 150 * scale, 350 * scale))
    circle(Surface, (244, 227, 215), (x + local_cord(0,  scale), y + local_cord(0, scale)), 50 * scale)



def morozhka(Surface, x, y, scale):

    '''(function) morozhka : (Surface, x, y, scale). 
     Function draws an ice cream with start coordinates in right down rectangle's corner.
    rect normal size : <- 86, -> 0, v 0, ^ 91. '''

    polygon(Surface, (255, 204, 0), [(x + local_cord(0, scale), y + local_cord(0, scale)), (x + local_cord(-55, scale), y + local_cord(-35, scale)), (x + local_cord(-10, scale), y + local_cord(-80, scale))])
    circle(Surface, (85, 0, 0), (x + local_cord(-45, scale), y + local_cord(-50, scale)), 16 * scale)
    circle(Surface, (255, 0, 0), (x + local_cord(-25, scale), y + local_cord(-70, scale)), 16 * scale)
    circle(Surface, (255, 255, 255), (x + local_cord(-50, scale), y + local_cord(-75, scale)),16 * scale)



def chuviha(Surface, x, y, scale, right_up, left_up):

    '''(function) chuviha : (Surface, x, y, scale, right_up, left_up) 
     right_up and left_up - bool, If = True right or left hand up
    Function draws a girl with start coordinates atthe centre of her head.
    rect object normal size : <- 185 , -> 185, v 485, ^ 50.'''

    if right_up == True:
        right_up = -1
    else:
        right_up = 1

    if left_up == True:
        left_up = -1
    else:
        left_up = 1
    
    #arms
    line(Surface, (0, 0, 0), (x + local_cord(-15, scale), y + local_cord(60, scale)), (x + local_cord(-100, scale), y + local_cord(145, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(15, scale), y + local_cord(60, scale)), (x + local_cord(100, scale), y + local_cord(145, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(100, scale), y + local_cord(145, scale)), (x + local_cord(185, scale), y + local_cord(145 + left_up * 85, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(-100, scale), y + local_cord(145, scale)), (x + local_cord(-185, scale), y + local_cord(145 + right_up * 85, scale)), 1)

    #legs
    line(Surface, (0, 0, 0), (x + local_cord(-30, scale), y + local_cord(365, scale)), (x + local_cord(-30, scale), y + local_cord(485, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(30, scale), y + local_cord(365, scale)), (x + local_cord(30, scale), y + local_cord(485, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(-30, scale), y + local_cord(485, scale)), (x + local_cord(-90, scale), y + local_cord(485, scale)), 1)
    line(Surface, (0, 0, 0), (x + local_cord(30, scale), y + local_cord(485, scale)), (x + local_cord(90, scale), y + local_cord(485, scale)), 1)

    #head and body
    polygon(Surface, (255, 85, 221), [(x + local_cord(0, scale), y + local_cord(0, scale)), (x + local_cord(-100, scale), y + local_cord(365, scale)), (x + local_cord(100, scale), y + local_cord(365, scale))])
    circle(Surface, (244, 227, 215), (x + local_cord(0, scale), y + local_cord(0, scale)), 50 * scale)



def sharik(Surface, x, y, scale):

    """(function) sharik : (Surface, x, y, scale)
    Function draws a baloon with start coordinates in the left down ractangle's corner.
    rect normal size : <- 0, -> 76, v 0, ^ 261"""
    
    line(Surface, (0, 0, 0), (x + local_cord(0, scale), y + local_cord(0, scale)), (x + local_cord(20, scale), y + local_cord(-150, scale)), 1)
    polygon(Surface, (255, 0, 0), [(x + local_cord(20, scale), y + local_cord(-150, scale)), (x + local_cord(0, scale), y + local_cord(-235, scale)),(x + local_cord(70, scale), y + local_cord(-220, scale))])
    circle(Surface, (255, 0, 0), (x + local_cord(55, scale), y + local_cord(-230, scale)), scale * 21)
    circle(Surface, (255, 0, 0), (x + local_cord(19, scale), y + local_cord(-240, scale)), scale * 21)



"""Фон
Небо, земля"""
rect(screen, (170, 238, 255), (0, 0, 1032, 384))
rect(screen, (55, 200, 113), (0, 380, 1032, 384))



chuvak(screen, 200, 300, 0.5 )
chuviha(screen, 385, 300, 0.5, False, True)
chuviha(screen, 570, 300, 0.5, True, False)
chuvak(screen, 755, 300, 0.5)


screen2 = pygame.Surface((76 , 261), pygame.SRCALPHA)
sharik(screen2, 0, 261, 1)
screen2 = pygame.transform.flip(screen2, True, False)
screen.blit(screen2, (29, 150))

line(screen, (0, 0, 0), (477.5, 331), (500, 150))
morozhka(screen, 500, 150, 1.5)



screen1 = pygame.Surface((129 , 137), pygame.SRCALPHA)
morozhka(screen1, 129, 137, 1)
screen1 = pygame.transform.flip(screen1, True, False)
screen.blit(screen1, (850, 280))



pygame.display.flip()
clock = pygame.time.Clock()
finished = False

while not finished:
    clock.tick(FPS)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            finished = True

pygame.quit()

