Compare commits

..

3 Commits

Author SHA1 Message Date
Игорь
42872cd9b1 ещё переделать надо 2026-03-04 15:46:57 +03:00
Игорь
6b0a46907b сделал номер 2 2026-03-04 14:48:01 +03:00
Игорь
18a202ae20 сделал номер 2 2026-03-04 14:46:08 +03:00
7 changed files with 265 additions and 0 deletions

0
2.py
View File

0
3.py
View File

View File

78
Task_2.py Normal file
View File

@@ -0,0 +1,78 @@
import pygame
import sys
import math
pygame.init()
# Настройки экрана
WIDTH, HEIGHT = 1200, 800
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Горный пейзаж")
# Цвета
SKY = (255, 200, 125) # небо
SUN = (255, 255, 0) # солнце
BEIGE = (245, 220, 200) # полоса
MOUNTAINS_FAR = (255, 100, 0) # дальние горы
MOUNTAINS_NEAR = (150, 0, 0) # ближние горы
GROUND = (200, 100, 200) # земля
def rotate_point(point, center, angle_deg):
"""Поворачивает точку относительно центра по часовой стрелке"""
angle_rad = math.radians(angle_deg)
x, y = point
cx, cy = center
x -= cx
y -= cy
x_rotated = x * math.cos(angle_rad) + y * math.sin(angle_rad)
y_rotated = -x * math.sin(angle_rad) + y * math.cos(angle_rad)
return (x_rotated + cx, y_rotated + cy)
def draw_mountain_rotated(surface, color, points, center, angle):
"""Рисует повёрнутую гору"""
rotated_points = [rotate_point(p, center, angle) for p in points]
pygame.draw.polygon(surface, color, rotated_points)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill(SKY)
pygame.draw.rect(screen, BEIGE, (0, 120, WIDTH, 200))
pygame.draw.circle(screen, SUN, (WIDTH//2, 80), 50)
rotate_center = (WIDTH//3, 300)
far_mountains_points = [
(-100, 520), (0, 420), (100, 440), (200, 400), (300, 430),
(400, 390), (500, 420), (600, 380), (700, 410), (800, 370),
(900, 400), (1000, 360), (1100, 390), (1200, 350), (1300, 380),
(1400, 340), (1500, 420), (1600, 520)
]
draw_mountain_rotated(screen, MOUNTAINS_FAR, far_mountains_points, rotate_center, 5)
pygame.draw.polygon(screen, MOUNTAINS_NEAR,
[(-200, HEIGHT-150), (-50, 590), (100, 630), (250, 570), (400, 610),
(550, 550), (700, 590), (850, 530), (1000, 570), (1150, 510),
(1300, 550), (1450, 490), (1600, 530), (1750, 450), (1900, HEIGHT-170)])
pygame.draw.rect(screen, GROUND, (0, HEIGHT-165, WIDTH, 1000))
pygame.display.flip()
pygame.quit()
sys.exit()

94
Task_3.py Normal file
View File

@@ -0,0 +1,94 @@
import pygame
import sys
import math
import random
pygame.init()
WIDTH, HEIGHT = 1200, 800
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Горный пейзаж")
# Цвета
SKY = (255, 200, 125) # небо
SUN = (255, 255, 0) # солнце
BEIGE = (245, 220, 200) # полоса
MOUNTAINS_FAR = (255, 100, 0) # дальние горы
MOUNTAINS_NEAR = (150, 0, 0) # ближние горы
GROUND = (200, 100, 200) # земля
MOUNTAINS_DARK = (5, 0, 5) # очень тёмные горы по краям
BIRD_COLOR = (0, 0, 0) # чёрные птички
def rotate_point(point, center, angle_deg):
"""Поворачивает точку относительно центра по часовой стрелке"""
angle_rad = math.radians(angle_deg)
x, y = point
cx, cy = center
x -= cx
y -= cy
x_rotated = x * math.cos(angle_rad) + y * math.sin(angle_rad)
y_rotated = -x * math.sin(angle_rad) + y * math.cos(angle_rad)
return (x_rotated + cx, y_rotated + cy)
def draw_mountain_rotated(surface, color, points, center, angle):
"""Рисует повёрнутую гору"""
rotated_points = [rotate_point(p, center, angle) for p in points]
pygame.draw.polygon(surface, color, rotated_points)
screen.fill(SKY)
pygame.draw.rect(screen, BEIGE, (0, 120, WIDTH, 200))
pygame.draw.circle(screen, SUN, (WIDTH//2, 80), 50)
rotate_center = (WIDTH//3, 300)
far_mountains_points = [
(-100, 520), (0, 420), (100, 440), (200, 400), (300, 430),
(400, 390), (500, 420), (600, 380), (700, 410), (800, 370),
(900, 400), (1000, 360), (1100, 390), (1200, 350), (1300, 380),
(1400, 340), (1500, 420), (1600, 520)
]
draw_mountain_rotated(screen, MOUNTAINS_FAR, far_mountains_points, rotate_center, 5)
pygame.draw.polygon(screen, MOUNTAINS_NEAR,
[(-200, HEIGHT-150), (-50, 590), (100, 630), (250, 570), (400, 610),
(550, 550), (700, 590), (850, 530), (1000, 570), (1150, 510),
(1300, 550), (1450, 490), (1600, 530), (1750, 450), (1900, HEIGHT-170)])
pygame.draw.rect(screen, GROUND, (0, HEIGHT-165, WIDTH, 1000))
pygame.draw.polygon(screen, MOUNTAINS_DARK,
[(-500, HEIGHT), (-300, 350), (-100, 480), (100, 520), (250, HEIGHT)])
pygame.draw.polygon(screen, MOUNTAINS_DARK,
[(800, HEIGHT), (950, 380), (1150, 420), (1350, 450), (1600, HEIGHT)])
for i in range(12):
x = random.randint(200, 1000)
y = random.randint(450, 600)
size = random.randint(15, 20)
pygame.draw.line(screen, BIRD_COLOR, (x, y), (x - size, y - size//3), 3)
pygame.draw.line(screen, BIRD_COLOR, (x - size, y - size//3), (x - size*2, y), 3)
pygame.draw.line(screen, BIRD_COLOR, (x, y), (x + size, y - size//3), 3)
pygame.draw.line(screen, BIRD_COLOR, (x + size, y - size//3), (x + size*2, y), 3)
pygame.draw.circle(screen, BIRD_COLOR, (x, y), 2)
pygame.display.update()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
sys.exit()

93
Test.py Normal file
View File

@@ -0,0 +1,93 @@
import pygame
import sys
import math
import random
pygame.init()
WIDTH, HEIGHT = 1200, 800
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Горный пейзаж")
# Цвета
SKY = (255, 200, 125) # небо
SUN = (255, 255, 0) # солнце
BEIGE = (245, 220, 200) # полоса
MOUNTAINS_FAR = (255, 100, 0) # дальние горы
MOUNTAINS_NEAR = (150, 0, 0) # ближние горы
GROUND = (200, 100, 200) # земля
MOUNTAINS_DARK = (5, 0, 5) # очень тёмные горы по краям
BIRD_COLOR = (0, 0, 0) # чёрные птички
def rotate_point(point, center, angle_deg):
"""Поворачивает точку относительно центра по часовой стрелке"""
angle_rad = math.radians(angle_deg)
x, y = point
cx, cy = center
x -= cx
y -= cy
x_rotated = x * math.cos(angle_rad) + y * math.sin(angle_rad)
y_rotated = -x * math.sin(angle_rad) + y * math.cos(angle_rad)
return (x_rotated + cx, y_rotated + cy)
def draw_mountain_rotated(surface, color, points, center, angle):
"""Рисует повёрнутую гору"""
rotated_points = [rotate_point(p, center, angle) for p in points]
pygame.draw.polygon(surface, color, rotated_points)
screen.fill(SKY)
pygame.draw.rect(screen, BEIGE, (0, 120, WIDTH, 200))
pygame.draw.circle(screen, SUN, (WIDTH//2, 80), 50)
rotate_center = (WIDTH//3, 300)
far_mountains_points = [
(-100, 520), (0, 420), (100, 440), (200, 400), (300, 430),
(400, 390), (500, 420), (600, 380), (700, 410), (800, 370),
(900, 400), (1000, 360), (1100, 390), (1200, 350), (1300, 380),
(1400, 340), (1500, 420), (1600, 520)
]
draw_mountain_rotated(screen, MOUNTAINS_FAR, far_mountains_points, rotate_center, 5)
pygame.draw.polygon(screen, MOUNTAINS_NEAR,
[(-200, HEIGHT-150), (-50, 590), (100, 630), (250, 570), (400, 610),
(550, 550), (700, 590), (850, 530), (1000, 570), (1150, 510),
(1300, 550), (1450, 490), (1600, 530), (1750, 450), (1900, HEIGHT-170)])
pygame.draw.rect(screen, GROUND, (0, HEIGHT-165, WIDTH, 1000))
pygame.draw.polygon(screen, MOUNTAINS_DARK,
[(-500, HEIGHT), (-300, 350), (-100, 480), (100, 520), (250, HEIGHT)])
pygame.draw.polygon(screen, MOUNTAINS_DARK,
[(800, HEIGHT), (950, 380), (1150, 420), (1350, 450), (1600, HEIGHT)])
for i in range(12):
x = random.randint(200, 1000)
y = random.randint(450, 600)
size = random.randint(15, 20)
pygame.draw.line(screen, BIRD_COLOR, (x, y), (x - size, y - size//3), 3)
pygame.draw.line(screen, BIRD_COLOR, (x - size, y - size//3), (x - size*2, y), 3)
pygame.draw.line(screen, BIRD_COLOR, (x, y), (x + size, y - size//3), 3)
pygame.draw.line(screen, BIRD_COLOR, (x + size, y - size//3), (x + size*2, y), 3)
pygame.draw.circle(screen, BIRD_COLOR, (x, y), 2)
pygame.display.update()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
sys.exit()

Binary file not shown.