Compare commits
4 Commits
aee216b2a5
...
add-hare
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47bc63b7c6 | ||
| 7a6a0e2696 | |||
|
|
a1bb978827 | ||
| ef3f80babb |
65
hare.py
65
hare.py
@@ -1,65 +0,0 @@
|
||||
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):
|
||||
body_width = width // 2
|
||||
body_height = height // 2
|
||||
body_y = y + body_height // 2
|
||||
draw_body(surface, x, body_y, body_width, body_height, color)
|
||||
|
||||
head_size = height // 4
|
||||
head_y = y - head_size // 2
|
||||
draw_head(surface, x, head_y, head_size, color)
|
||||
|
||||
ear_height = height // 3
|
||||
ear_y = y - height // 2 + ear_height // 2
|
||||
for ear_x in (x - head_size // 4, x + head_size // 4):
|
||||
draw_ear(surface, ear_x, ear_y, width // 8, ear_height, color)
|
||||
|
||||
leg_height = height // 16
|
||||
leg_y = y + height // 2 - leg_height // 2
|
||||
for leg_x in (x - width // 4, x + width // 4):
|
||||
draw_leg(surface, leg_x, leg_y, width // 4, leg_height, 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()
|
||||
4
task1.py
4
task1.py
@@ -26,12 +26,10 @@ def draw_ear(surface, x, y, width, height, color):
|
||||
|
||||
def draw_leg(surface, x, y, width, height, color):
|
||||
"""Рисует ногу зайца."""
|
||||
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
|
||||
|
||||
def draw_hare(surface, center_x, center_y, total_width, total_height, color):
|
||||
"""
|
||||
Рисует зайца на экране.
|
||||
|
||||
|
||||
Параметры:
|
||||
surface: поверхность для рисования
|
||||
center_x, center_y: координаты центра изображения
|
||||
|
||||
Reference in New Issue
Block a user