forked from 24_DemkinDE/lab3prog
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
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(surface, x, y, width, height, color):
|
||
draw_body(surface, x, y + height // 4, width // 2, height // 2, color)
|
||
draw_ear(surface, x - height // 16, y - height // 2 + height // 6, width // 8, height // 3, color)
|
||
draw_ear(surface, x + height // 16, y - height // 2 + height // 6, width // 8, height // 3, color)
|
||
draw_head(surface, x, y - height // 8, height // 4, color)
|
||
draw_leg(surface, x - width // 4, y + height // 2 - height // 32, width // 4, height // 16, color)
|
||
draw_leg(surface, x + width // 4, y + height // 2 - height // 32, width // 4, height // 16, color)
|
||
|
||
# Рисуем зайца
|
||
draw_hare(screen, 200, 200, 200, 300, GRAY)
|
||
|
||
# Глаза и нос - НАХОДЯТСЯ ВНЕ ФУНКЦИИ
|
||
circle(screen, BLACK, (170, 150), 5) # левый глаз
|
||
circle(screen, BLACK, (230, 150), 5) # правый глаз
|
||
circle(screen, BLACK, (200, 170), 3) # носик
|
||
|
||
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()
|