import pygame from pygame.draw import * pygame.init() FPS = 30 screen = pygame.display.set_mode((400, 400)) # Используемые цвета BLACK = (0, 0, 0) WHITE = (255, 255, 255) PINK = (255, 200, 200) DARK_PINK = (255, 150, 150) LIGHT_GREEN = (220, 255, 220) BROWN = (180, 130, 80) DARK_BROWN = (160, 110, 60) def draw_ellipse(surface, x, y, width, height, color): """Рисует эллипс по центру с координатами x,y""" ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) def draw_body(surface, x, y, width, height, color): """Рисует тело зайца""" draw_ellipse(surface, x, y, width, height, color) def draw_ear(surface, x, y, width, height, color): """Рисует ухо зайца""" draw_ellipse(surface, x, y, width, height, color) # Добавляем внутреннюю часть уха (розовую) draw_ellipse(surface, x, y + 3, width // 2, height // 1.5, PINK) def draw_head(surface, x, y, size, color): """Рисует голову зайца""" circle(surface, color, (x, y), size // 2) def draw_eyes(surface, x, y, head_size): """Рисует глаза зайца""" eye_size = head_size // 8 # Белки глаз for offset_x in (-head_size // 5, head_size // 5): circle(surface, WHITE, (x + offset_x, y - head_size // 8), int(eye_size // 1.5)) # Зрачки circle(surface, BLACK, (x + offset_x, y - head_size // 8), eye_size // 3) # Нос circle(surface, DARK_PINK, (x, y + head_size // 10), eye_size // 2) def draw_leg(surface, x, y, width, height, color): """Рисует ногу зайца""" draw_ellipse(surface, x, y, width, height, color) def draw_hare(surface, x, y, width, height, color): """Рисует зайца на экране""" # Параметры body_width = width // 2 body_height = height // 2 body_y = y + body_height // 4 head_size = height // 3 head_y = y - head_size // 2 # Тело draw_body(surface, x, body_y, body_width, body_height, color) # Уши (должны быть под головой) ear_height = height // 3 ear_y = y - height // 2 + ear_height // 2 ear_width = width // 10 for ear_x in (x - head_size // 4, x + head_size // 4): draw_ear(surface, ear_x, ear_y, ear_width, ear_height, color) # Голова (рисуем поверх ушей) draw_head(surface, x, head_y, head_size, color) # Глаза и нос draw_eyes(surface, x, head_y, head_size) # Задние лапы back_leg_height = height // 10 back_leg_y = y + height // 3 back_leg_width = width // 3 for leg_x in (x - width // 5, x + width // 5): draw_leg(surface, leg_x, back_leg_y, back_leg_width, back_leg_height, color) # Передние лапы front_leg_height = height // 4 front_leg_y = y + height // 12 front_leg_width = width // 7 for leg_x in (x - width // 5, x + width // 5): draw_leg(surface, leg_x, front_leg_y, front_leg_width, front_leg_height, color) # Маленькие лапки (ступни) foot_width = front_leg_width // 1.2 foot_height = front_leg_height // 4 foot_y = front_leg_y + front_leg_height // 1.8 for leg_x in (x - width // 5, x + width // 5): draw_leg(surface, leg_x, foot_y, foot_width, foot_height, DARK_BROWN) # Основная программа screen.fill(LIGHT_GREEN) draw_hare(screen, 200, 200, 240, 380, BROWN) pygame.display.update() 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()