144 lines
4.5 KiB
Python
Executable File
144 lines
4.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import pygame
|
|
from pygame.draw import *
|
|
|
|
pygame.init()
|
|
|
|
FPS = 30
|
|
screen = pygame.display.set_mode((600, 600))
|
|
clock = pygame.time.Clock()
|
|
|
|
# ================= ORIGINAL FUNCTIONS =================
|
|
|
|
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)
|
|
|
|
# пузико
|
|
circle(surface, (255, 255, 255), (x, body_y), body_width // 4)
|
|
|
|
# голова
|
|
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)
|
|
|
|
# ПЕРЕДНИЕ лапы (перерисовал нормально — как овальные лапки снизу)
|
|
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_radius = head_size // 8
|
|
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, (0, 0, 0), (eye_x, eye_y), eye_radius // 2)
|
|
|
|
# нос
|
|
nose_y = head_y + head_size // 8
|
|
polygon(surface, (255, 150, 150), [
|
|
(x, nose_y),
|
|
(x - head_size // 8, nose_y + head_size // 12),
|
|
(x + head_size // 8, nose_y + head_size // 12)
|
|
])
|
|
|
|
|
|
# ================= EXTRA OBJECTS =================
|
|
|
|
def draw_sun(surface):
|
|
circle(surface, (255, 220, 0), (520, 80), 40)
|
|
|
|
|
|
def draw_cloud(surface, x, y):
|
|
circle(surface, (255, 255, 255), (x, y), 20)
|
|
circle(surface, (255, 255, 255), (x + 20, y), 25)
|
|
circle(surface, (255, 255, 255), (x + 40, y), 20)
|
|
|
|
|
|
def draw_house(surface):
|
|
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()
|
|
|
|
# ================= LOOP =================
|
|
running = True
|
|
while running:
|
|
clock.tick(FPS)
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
running = False
|
|
|
|
pygame.quit()
|