forked from 24_LitvintsevaVD/YP_2026_litvintseva
Обновить rabit2.py
This commit is contained in:
133
rabit2.py
133
rabit2.py
@@ -5,83 +5,59 @@ from pygame.draw import *
|
|||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
FPS = 30
|
FPS = 30
|
||||||
screen = pygame.display.set_mode((600, 600))
|
screen = pygame.display.set_mode((400, 400))
|
||||||
clock = pygame.time.Clock()
|
|
||||||
|
|
||||||
# ================= ORIGINAL FUNCTIONS =================
|
|
||||||
|
|
||||||
def draw_body(surface, x, y, width, height, color):
|
def draw_body(surface, x, y, width, height, color):
|
||||||
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
|
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
|
||||||
|
|
||||||
|
|
||||||
def draw_head(surface, x, y, size, color):
|
def draw_head(surface, x, y, size, color):
|
||||||
circle(surface, color, (x, y), size // 2)
|
circle(surface, color, (x, y), size // 2)
|
||||||
|
|
||||||
|
|
||||||
def draw_ear(surface, x, y, width, height, color):
|
def draw_ear(surface, x, y, width, height, color):
|
||||||
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
|
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
|
||||||
|
|
||||||
|
|
||||||
def draw_leg(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))
|
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
|
||||||
|
|
||||||
|
|
||||||
def draw_hare(surface, x, y, width, height, color):
|
def draw_hare(surface, x, y, width, height, color):
|
||||||
# тело
|
|
||||||
body_width = width // 2
|
body_width = width // 2
|
||||||
body_height = height // 2
|
body_height = height // 2
|
||||||
body_y = y + body_height // 2
|
body_y = y + body_height // 2
|
||||||
draw_body(surface, x, body_y, body_width, body_height, color)
|
draw_body(surface, x, body_y, body_width, body_height, color)
|
||||||
|
|
||||||
# пузико
|
|
||||||
circle(surface, (255, 255, 255), (x, body_y), body_width // 4)
|
|
||||||
|
|
||||||
# голова
|
|
||||||
head_size = height // 4
|
head_size = height // 4
|
||||||
head_y = y - head_size // 2
|
head_y = y - head_size // 2
|
||||||
draw_head(surface, x, head_y, head_size, color)
|
draw_head(surface, x, head_y, head_size, color)
|
||||||
|
|
||||||
# уши
|
|
||||||
ear_height = height // 3
|
ear_height = height // 3
|
||||||
ear_y = y - height // 2 + ear_height // 2
|
ear_y = y - height // 2 + ear_height // 2
|
||||||
for ear_x in (x - head_size // 4, x + head_size // 4):
|
for ear_x in (x - head_size // 4, x + head_size // 4):
|
||||||
draw_ear(surface, ear_x, ear_y, width // 8, ear_height, color)
|
draw_ear(surface, ear_x, ear_y, width // 8, ear_height, color)
|
||||||
|
|
||||||
# задние лапы
|
|
||||||
leg_height = height // 16
|
leg_height = height // 16
|
||||||
leg_y = y + height // 2 - leg_height // 2
|
leg_y = y + height // 2 - leg_height // 2
|
||||||
for leg_x in (x - width // 4, x + width // 4):
|
for leg_x in (x - width // 4, x + width // 4):
|
||||||
draw_leg(surface, leg_x, leg_y, width // 4, leg_height, color)
|
draw_leg(surface, leg_x, leg_y, width // 4, leg_height, color)
|
||||||
|
|
||||||
# ПЕРЕДНИЕ лапы (перерисовал нормально — как овальные лапки снизу)
|
# Добавляем детали
|
||||||
front_w = width // 8
|
|
||||||
front_h = height // 10
|
|
||||||
front_y = y + height // 5
|
|
||||||
|
|
||||||
# делаем их более «лежащими» и аккуратными
|
# Глаза (белки)
|
||||||
# сначала рисуем лапы
|
|
||||||
ellipse(surface, color, (x - width // 5 - front_w//2, front_y, front_w, front_h))
|
|
||||||
ellipse(surface, color, (x + width // 5 - front_w//2, front_y, front_w, front_h))
|
|
||||||
|
|
||||||
# затем поверх — ТОЛЬКО розовые подушечки (полностью перекрывают центр)
|
|
||||||
circle(surface, (255, 220, 220), (x - width // 5, front_y + front_h//2), front_h//3)
|
|
||||||
circle(surface, (255, 220, 220), (x + width // 5, front_y + front_h//2), front_h//3)
|
|
||||||
|
|
||||||
# небольшие "подушечки" (деталь)
|
|
||||||
circle(surface, (255, 220, 220), (x - width // 5, front_y + front_h//2), front_h//4)
|
|
||||||
circle(surface, (255, 220, 220), (x + width // 5, front_y + front_h//2), front_h//4)
|
|
||||||
|
|
||||||
# хвостик
|
|
||||||
circle(surface, color, (x + body_width // 2, body_y), body_width // 8)
|
|
||||||
|
|
||||||
# глаза
|
|
||||||
eye_y = head_y - head_size // 8
|
eye_y = head_y - head_size // 8
|
||||||
eye_radius = head_size // 8
|
eye_radius = head_size // 8
|
||||||
for eye_x in (x - head_size // 6, x + head_size // 6):
|
for eye_x in (x - head_size // 6, x + head_size // 6):
|
||||||
circle(surface, (255, 255, 255), (eye_x, eye_y), eye_radius)
|
circle(surface, (255, 255, 255), (eye_x, eye_y), eye_radius)
|
||||||
circle(surface, (0, 0, 0), (eye_x, eye_y), eye_radius // 2)
|
|
||||||
|
|
||||||
# нос
|
# Зрачки
|
||||||
|
pupil_radius = eye_radius // 2
|
||||||
|
for pupil_x in (x - head_size // 6, x + head_size // 6):
|
||||||
|
circle(surface, (0, 0, 0), (pupil_x, eye_y), pupil_radius)
|
||||||
|
|
||||||
|
# Блики в глазах
|
||||||
|
spark_radius = pupil_radius // 3
|
||||||
|
for spark_x in (x - head_size // 6 - 2, x + head_size // 6 - 2):
|
||||||
|
circle(surface, (255, 255, 255), (spark_x, eye_y - 2), spark_radius)
|
||||||
|
|
||||||
|
# Носик (розовый треугольник)
|
||||||
nose_y = head_y + head_size // 8
|
nose_y = head_y + head_size // 8
|
||||||
polygon(surface, (255, 150, 150), [
|
polygon(surface, (255, 150, 150), [
|
||||||
(x, nose_y),
|
(x, nose_y),
|
||||||
@@ -89,55 +65,60 @@ def draw_hare(surface, x, y, width, height, color):
|
|||||||
(x + head_size // 8, nose_y + head_size // 12)
|
(x + head_size // 8, nose_y + head_size // 12)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# Ротик
|
||||||
|
line(surface, (150, 100, 100),
|
||||||
|
(x, nose_y + head_size // 16),
|
||||||
|
(x, nose_y + head_size // 8), 2)
|
||||||
|
|
||||||
# ================= EXTRA OBJECTS =================
|
# Немного румянца на щечках
|
||||||
|
blush_radius = head_size // 10
|
||||||
|
for cheek_x in (x - head_size // 4, x + head_size // 4):
|
||||||
|
circle(surface, (255, 200, 200), (cheek_x, nose_y + head_size // 24), blush_radius)
|
||||||
|
|
||||||
def draw_sun(surface):
|
# Усики (по три с каждой стороны) - теперь после румянца
|
||||||
circle(surface, (255, 220, 0), (520, 80), 40)
|
whisker_y = nose_y + head_size // 24
|
||||||
|
whisker_length = head_size // 4
|
||||||
|
for i in range(3):
|
||||||
|
# Левые усики
|
||||||
|
line(surface, (100, 100, 100),
|
||||||
|
(x - head_size // 10, whisker_y + i * 2),
|
||||||
|
(x - whisker_length - head_size // 10, whisker_y - head_size // 10 + i * 2), 1)
|
||||||
|
# Правые усики
|
||||||
|
line(surface, (100, 100, 100),
|
||||||
|
(x + head_size // 10, whisker_y + i * 2),
|
||||||
|
(x + whisker_length + head_size // 10, whisker_y - head_size // 10 + i * 2), 1)
|
||||||
|
|
||||||
|
# Передние лапки (две маленькие) - с обводкой
|
||||||
|
front_leg_width = width // 12
|
||||||
|
front_leg_height = height // 8
|
||||||
|
front_leg_y = y + height // 6
|
||||||
|
|
||||||
def draw_cloud(surface, x, y):
|
# Левая передняя лапка (с обводкой)
|
||||||
circle(surface, (255, 255, 255), (x, y), 20)
|
ellipse(surface, color, (x - width // 6 - front_leg_width // 2,
|
||||||
circle(surface, (255, 255, 255), (x + 20, y), 25)
|
front_leg_y - front_leg_height // 2,
|
||||||
circle(surface, (255, 255, 255), (x + 40, y), 20)
|
front_leg_width, front_leg_height))
|
||||||
|
ellipse(surface, (0, 0, 0), (x - width // 6 - front_leg_width // 2,
|
||||||
|
front_leg_y - front_leg_height // 2,
|
||||||
|
front_leg_width, front_leg_height), 1)
|
||||||
|
|
||||||
|
# Правая передняя лапка (с обводкой)
|
||||||
|
ellipse(surface, color, (x + width // 6 - front_leg_width // 2,
|
||||||
|
front_leg_y - front_leg_height // 2,
|
||||||
|
front_leg_width, front_leg_height))
|
||||||
|
ellipse(surface, (0, 0, 0), (x + width // 6 - front_leg_width // 2,
|
||||||
|
front_leg_y - front_leg_height // 2,
|
||||||
|
front_leg_width, front_leg_height), 1)
|
||||||
|
|
||||||
def draw_house(surface):
|
draw_hare(screen, 200, 200, 200, 400, (200, 200, 200))
|
||||||
rect(surface, (200, 150, 100), (50, 350, 120, 120))
|
|
||||||
polygon(surface, (150, 75, 0), [(50, 350), (110, 300), (170, 350)])
|
|
||||||
|
|
||||||
|
|
||||||
def draw_carrot(surface, x, y):
|
|
||||||
polygon(surface, (255, 120, 0), [(x, y), (x - 10, y + 30), (x + 10, y + 30)])
|
|
||||||
line(surface, (0, 200, 0), (x, y), (x, y - 15), 3)
|
|
||||||
|
|
||||||
|
|
||||||
def draw_grass(surface):
|
|
||||||
for i in range(0, 600, 10):
|
|
||||||
line(surface, (0, 180, 0), (i, 580), (i + 5, 560), 2)
|
|
||||||
|
|
||||||
|
|
||||||
# ================= DRAW =================
|
|
||||||
screen.fill((255, 255, 255))
|
|
||||||
|
|
||||||
draw_sun(screen)
|
|
||||||
draw_cloud(screen, 150, 80)
|
|
||||||
draw_cloud(screen, 250, 60)
|
|
||||||
draw_house(screen)
|
|
||||||
draw_carrot(screen, 450, 500)
|
|
||||||
draw_grass(screen)
|
|
||||||
|
|
||||||
# один кролик
|
|
||||||
draw_hare(screen, 300, 300, 200, 400, (200, 200, 200))
|
|
||||||
|
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
finished = False
|
||||||
|
|
||||||
# ================= LOOP =================
|
while not finished:
|
||||||
running = True
|
|
||||||
while running:
|
|
||||||
clock.tick(FPS)
|
clock.tick(FPS)
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
finished = True
|
||||||
|
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
|||||||
Reference in New Issue
Block a user