Files
2/task1.py
2026-03-18 13:29:25 +03:00

61 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pygame
from pygame.draw import*
pygame.init()
FPS = 30
screen = pygame.display.set_mode((400,400))
WHITE = (255, 255, 255)
GRAY = (200, 200, 200)
BLACK = (0, 0, 0)
BROWN = (139, 69, 19)
#Рисунок
def draw_body(surface, x, y, width, height, color):
''' Рисует тело '''
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
def draw_head(surface, x, y, size, color):
''' Рисует голову '''
circle(surface, color, (x, y), size // 2)
def draw_ear(surface, x, y, width, height, color):
''' Рисует ухо '''
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
def draw_leg(surface, x, y, width, height, color):
''' Рисует ногу '''
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
def draw_hare(srf, cx, cy, w, h, clr):
''' Рисует зайца '''
bw = w // 2
bh = h // 2
by = cy + bh // 2
draw_body(srf, cx, by, bw, bh, clr)
hs = h // 4
hy = cy - hs // 2
draw_head(srf, cx, hy, hs, clr)
eh = h // 3
ey = cy - h // 2 + eh // 2
for ex in (cx - hs // 4, cx + hs // 4):
draw_ear(srf, ex, ey, w // 8, eh, clr)
lh = h // 16
ly = cy + h // 2 - lh // 2
coords = [cx - w // 4, cx + w // 4]
for lx in coords:
draw_leg(srf, lx, ly, w // 4, lh, clr)
draw_hare(screen, 200, 200, 200, 400, 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()