Compare commits

...

5 Commits

Author SHA1 Message Date
Игорь
85499b9d80 ff 2026-03-18 14:22:43 +03:00
69ef95dc15 Merge pull request 'add-hare' (#3) from add-hare into main
Reviewed-on: 24_PetrovIA/2#3
2026-03-18 14:15:57 +03:00
ef3f80babb Удалить hare.py 2026-03-18 14:15:02 +03:00
6606671945 Удалить hare.py 2026-03-18 14:08:42 +03:00
16b5661a26 Merge pull request 'базовый заяц' (#2) from add-hare into main
Reviewed-on: 24_PetrovIA/2#2
2026-03-18 13:03:34 +03:00
2 changed files with 23 additions and 21 deletions

8
1.code-workspace Normal file
View File

@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "../1"
}
],
"settings": {}
}

View File

@@ -1,56 +1,50 @@
import pygame import pygame
from pygame.draw import * from pygame.draw import*
pygame.init() pygame.init()
FPS = 30 FPS = 30
screen = pygame.display.set_mode((400, 400)) screen = pygame.display.set_mode((400,400))
# Цвета
WHITE = (255, 255, 255) WHITE = (255, 255, 255)
GRAY = (200, 200, 200) GRAY = (200, 200, 200)
BLACK = (0, 0, 0) BLACK = (0, 0, 0)
BROWN = (139, 69, 19) BROWN = (139, 69, 19)
#Рисунок
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)
head_size = height // 4 head_size = height // 4
head_y = y - head_size // 2 draw_head(surface, x, y-head_size // 2, 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)
# Рисуем зайца draw_hare(screen, 200, 200, 200, 400, BROWN)
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() pygame.display.update()
clock = pygame.time.Clock() clock = pygame.time.Clock()
@@ -62,4 +56,4 @@ while not finished:
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
finished = True finished = True
pygame.quit() pygame.quit()