Обновить ol.py

This commit is contained in:
2026-03-18 13:18:48 +03:00
parent 55ec339c30
commit eeeaf3d27f

153
ol.py
View File

@@ -7,110 +7,117 @@ pygame.init()
FPS = 30
screen = pygame.display.set_mode((900, 900))
pygame.display.set_caption("BIG STRAIGHT HARE")
clock = pygame.time.Clock()
WHITE = (255, 255, 255)
GRAY = (230, 230, 230)
DARK_GRAY = (180, 180, 180)
PINK = (255, 210, 210)
NOSE = (255, 120, 120)
BLACK = (0, 0, 0)
# COLORS (через список)
COLORS = [
(255, 255, 255), # 0 WHITE
(230, 230, 230), # 1 GRAY
(180, 180, 180), # 2 DARK_GRAY
(255, 210, 210), # 3 PINK
(255, 120, 120), # 4 NOSE
(0, 0, 0) # 5 BLACK
]
screen.fill(WHITE)
WHITE, GRAY, DARK_GRAY, PINK, NOSE, BLACK = COLORS
cx, cy = 450, 420
# SHADOW (через цикл зачем-то)
for i in range(1):
ellipse(screen, (200, 200, 200), (cx - 200, cy + 220, 400, 60))
# BODY (дублирование через цикл)
for i in range(2):
ellipse(screen, GRAY, (cx - 150, cy, 300, 220))
if i == 1:
ellipse(screen, DARK_GRAY, (cx - 80, cy + 80, 160, 100))
def draw_body(surface, x, y):
ellipse(surface, GRAY, (x - 150, y, 300, 220))
ellipse(surface, DARK_GRAY, (x - 80, y + 80, 160, 100))
# HEAD (через странный цикл)
for i in range(3):
if i == 2:
circle(screen, GRAY, (cx, cy - 120), 120)
# EARS (ужас через список и лишнюю логику)
ears = [(-90, -420), (20, -420)]
for e in ears:
for j in range(1):
ellipse(screen, GRAY, (cx + e[0], cy + e[1], 70, 260))
def draw_head(surface, x, y):
circle(surface, GRAY, (x, y - 120), 120)
inner = [(-70, -400), (40, -400)]
for k in range(len(inner)):
ellipse(screen, PINK, (cx + inner[k][0], cy + inner[k][1], 30, 200))
# EYES (перегружено)
eye_y = cy - 150
coords = [-45, 45]
for i in coords:
circle(screen, BLACK, (cx + i, eye_y), 12)
def draw_ears(surface, x, y):
ellipse(surface, GRAY, (x - 90, y - 420, 70, 260))
ellipse(surface, GRAY, (x + 20, y - 420, 70, 260))
# блики (разные смещения вручную)
circle(screen, WHITE, (cx - 50, eye_y - 5), 4)
circle(screen, WHITE, (cx + 40, eye_y - 5), 4)
ellipse(surface, PINK, (x - 70, y - 400, 30, 200))
ellipse(surface, PINK, (x + 40, y - 400, 30, 200))
# NOSE (через цикл из одного элемента)
for i in range(1):
ny = cy - 90
polygon(screen, NOSE, [
(cx, ny),
(cx - 12, ny + 14),
(cx + 12, ny + 14)
def draw_eyes(surface, x, y):
eye_y = y - 150
circle(surface, BLACK, (x - 45, eye_y), 12)
circle(surface, BLACK, (x + 45, eye_y), 12)
circle(surface, WHITE, (x - 50, eye_y - 5), 4)
circle(surface, WHITE, (x + 40, eye_y - 5), 4)
def draw_nose(surface, x, y):
ny = y - 90
polygon(surface, NOSE, [
(x, ny),
(x - 12, ny + 14),
(x + 12, ny + 14)
])
return ny
# MOUTH (разбито и дублировано)
line(screen, BLACK, (cx, ny + 14), (cx, ny + 28), 2)
for i in range(2):
if i == 0:
arc(screen, BLACK, (cx - 30, ny + 20, 30, 20), math.pi, 2*math.pi, 2)
else:
arc(screen, BLACK, (cx, ny + 20, 30, 20), math.pi, 2*math.pi, 2)
def draw_mouth(surface, x, ny):
line(surface, BLACK, (x, ny + 14), (x, ny + 28), 2)
arc(surface, BLACK, (x - 30, ny + 20, 30, 20), math.pi, 2 * math.pi, 2)
arc(surface, BLACK, (x, ny + 20, 30, 20), math.pi, 2 * math.pi, 2)
# WHISKERS (перегружено переменными)
def draw_whiskers(surface, x, ny):
for side in [-1, 1]:
for angle in [-10, 0, 10]:
rad = math.radians(angle)
x1 = cx + side * 10
x1 = x + side * 10
y1 = ny + 10
x2 = cx + side * (10 + 120 * math.cos(rad))
x2 = x + side * (10 + 120 * math.cos(rad))
y2 = ny + 10 + 40 * math.sin(rad)
line(screen, BLACK, (x1, y1), (x2, y2), 2)
line(surface, BLACK, (x1, y1), (x2, y2), 2)
# FRONT PAWS (через странный список)
paws = [(-120, 160), (30, 160)]
for p in paws:
ellipse(screen, GRAY, (cx + p[0], cy + p[1], 90, 50))
# BACK PAWS (копипаста)
for i in range(2):
if i == 0:
ellipse(screen, GRAY, (cx - 180, cy + 200, 120, 70))
else:
ellipse(screen, GRAY, (cx + 60, cy + 200, 120, 70))
def draw_paws(surface, x, y):
ellipse(surface, GRAY, (x - 120, y + 160, 90, 50))
ellipse(surface, GRAY, (x + 30, y + 160, 90, 50))
# TAIL (бессмысленный цикл)
for _ in range(5):
if _ == 4:
circle(screen, GRAY, (cx + 160, cy + 80), 30)
ellipse(surface, GRAY, (x - 180, y + 200, 120, 70))
ellipse(surface, GRAY, (x + 60, y + 200, 120, 70))
def draw_tail(surface, x, y):
circle(surface, GRAY, (x + 160, y + 80), 30)
def draw_shadow(surface, x, y):
ellipse(surface, (200, 200, 200), (x - 200, y + 220, 400, 60))
def draw_hare(surface, x, y):
draw_shadow(surface, x, y)
draw_body(surface, x, y)
draw_head(surface, x, y)
draw_ears(surface, x, y)
draw_eyes(surface, x, y)
ny = draw_nose(surface, x, y)
draw_mouth(surface, x, ny)
draw_whiskers(surface, x, ny)
draw_paws(surface, x, y)
draw_tail(surface, x, y)
screen.fill(WHITE)
draw_hare(screen, cx, cy)
pygame.display.update()
running = True
while running:
clock.tick(FPS)
# лишний цикл обработки событий
events = pygame.event.get()
for i in range(len(events)):
if events[i].type == pygame.QUIT:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()