Задание 3 с птичками

This commit is contained in:
2026-03-04 14:04:37 +03:00
parent 909f32b332
commit e78c35c9da

43
lab2/task3_gorpt.py Normal file
View File

@@ -0,0 +1,43 @@
import pygame
from pygame.draw import *
pygame.init()
FPS = 30
screen = pygame.display.set_mode((800, 500))
# небо
rect(screen, (230, 200, 160), (0, 0, 800, 500))
# дальний фон
rect(screen, (240, 210, 190), (0, 200, 800, 80))
# солнце
circle(screen, (255, 230, 0), (400, 150), 60)
# горы задний план
polygon(screen, (250, 150, 50), [(0,250), (200,120), (350,260),
(600,130), (800,250)])
# средний слой
polygon(screen, (180, 70, 50), [(0,350), (150,300), (250,360),
(400,310), (600,370), (800,320), (800,500), (0,500)])
# передний слой
polygon(screen, (60, 0, 40), [(0,500), (0,400), (150,350), (300,480), (500,420),
(650,460), (800,350), (800,500)])
# функция птицы
def bird(x, y, size):
arc(screen, (60, 30, 10), (x - size, y, size, size), 3.14 * 0.1 , 3.14 * 0.9, 3)
arc(screen, (60, 30, 10), (x, y, size, size), 3.14 * 0.1 , 3.14 * 0.9, 3)
# птицы в небе
bird(250, 220, 40)
bird(330, 240, 45)
bird(420, 230, 40)
bird(500, 210, 50)
# птицы над водой
bird(450, 400, 50)
bird(550, 420, 45)
bird(650, 410, 55)
bird(350, 430, 50)
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()