From 42872cd9b12e03575be10e476380b356d81e7174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Wed, 4 Mar 2026 15:46:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B5=D1=89=D1=91=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20=D0=BD=D0=B0=D0=B4=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3.py | 0 1.py => Task_1.py | 0 2.py => Task_2.py | 4 +- Task_3.py | 94 +++++++++++++++++++++++++++++ Test.py | 93 ++++++++++++++++++++++++++++ __pycache__/Task_2.cpython-313.pyc | Bin 0 -> 3480 bytes 6 files changed, 190 insertions(+), 1 deletion(-) delete mode 100644 3.py rename 1.py => Task_1.py (100%) rename 2.py => Task_2.py (98%) create mode 100644 Task_3.py create mode 100644 Test.py create mode 100644 __pycache__/Task_2.cpython-313.pyc diff --git a/3.py b/3.py deleted file mode 100644 index e69de29..0000000 diff --git a/1.py b/Task_1.py similarity index 100% rename from 1.py rename to Task_1.py diff --git a/2.py b/Task_2.py similarity index 98% rename from 2.py rename to Task_2.py index 612fb51..72a798f 100644 --- a/2.py +++ b/Task_2.py @@ -1,3 +1,4 @@ + import pygame import sys import math @@ -31,6 +32,7 @@ def rotate_point(point, center, angle_deg): 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] @@ -59,7 +61,7 @@ while running: (1400, 340), (1500, 420), (1600, 520) ] - draw_mountain_rotated(screen, MOUNTAINS_FAR, far_mountains_points, rotate_center, 10) + draw_mountain_rotated(screen, MOUNTAINS_FAR, far_mountains_points, rotate_center, 5) diff --git a/Task_3.py b/Task_3.py new file mode 100644 index 0000000..ef32053 --- /dev/null +++ b/Task_3.py @@ -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() \ No newline at end of file diff --git a/Test.py b/Test.py new file mode 100644 index 0000000..8b52879 --- /dev/null +++ b/Test.py @@ -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() \ No newline at end of file diff --git a/__pycache__/Task_2.cpython-313.pyc b/__pycache__/Task_2.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ce8e8ebfe1e377010db33e211c9e3883fb265d01 GIT binary patch literal 3480 zcma)8Yit|G5#A&3_!KEp56XI2reyg+$+D_ciXA&OB1KQQVr-shGZtZip(yGQ`l#+v zt_U;*DJ4?f7LDxMkrEUL1GE5R1PzhGt?bsR(O>@4;to#+tC5HRDp&QiHIAwE}grCAchDcDSJ4PlY@P!D z|Gu^p;rsedS ztzm1~I(9Ex&+cR0Yy;cK?q{3W1MERS9nw&3rT;g+-FK*zMPTJHu>ui!p4q3}GWHug zeJ*Yt?8;^~gosxq?P~2dDsv0EXkHt@= zlz3PAfq2_3{#Lvt-WGo)=EPrm^vYA1SMC$?1`v-PlLOHR94QEtzmv&FL`rUQ0ilc$ zK>_hjkuL~TASSg#<-&!$f-yqGJQ+VZ0=M@D8X+>Z`G~P+S|jpr-f~{=N2F3r_WCKc zj|Tc$s}SPpzZv|t#$xk- zO^eIG-4cH-{g8~^(i{x#N;8lQIg$tCHBwA!aNv5V{DkD3j-q10gB>PYvby7IR2bYH4_oo3SgFw(kphx2;R;=r{5 zz*ZcR9EY+EAB}xHadRSf=^BRIbd!;T9>19jG${n z0&oNH#PQ4sTnMcNSpQ}*KBF6QYK5OS0A}-&_;yJopRs6Rs}E3q!&c#oQi9G6Yx2xE z^5~|T0Vif4Nz&4+nnWZg#80HFYPFb!T$q)9kOJi? z^XRyrJbn69F#*H_KQv_Kr({N_7C3HM<4GA%7Bv1S@Z8TezMaVDRG#|+I!s<>uo(bD z%6C+`@*Ci}_cT25j>8)MO>hGf15nWa3OqNV$-fC8O#B2Nh^O2|%}xa*942oV*q;WT z8`kiTh+JD&c?lfF?%%3Q_<17Nbh(?v)xT+SaT=#(`gZ-5`Zcp# zGP^SevaZa&6?1#akO!kvpI=4CK+EV#>GOtiAf~DmlXvV*+49c1ls#|W zlQKM}OQ<7{>-5y|4GXfCri_0yz--lG-PO7^XM^Nyc;MXsJqGIX+b6D^SaQ8z`)=)L z)~39x_WS*xGpMX-!-NN`@h0&)3vv3>o1Ai&))~y|7$!?}B)CBwxKhb0Jr=JaWG!U)_{>J$Le+ z_5PSRd_f$!C=Fi}hekITU3G~1La%3DqhJrTXx8XL1m`lLtShJguqNkU?hy}kt