сделал номер 2
This commit is contained in:
41
2.py
41
2.py
@@ -1,10 +1,10 @@
|
||||
import pygame
|
||||
from pygame.draw import *
|
||||
import sys
|
||||
import math
|
||||
|
||||
pygame.init()
|
||||
|
||||
FPS = 30
|
||||
# Настройки экрана
|
||||
WIDTH, HEIGHT = 1200, 800
|
||||
screen = pygame.display.set_mode((WIDTH, HEIGHT))
|
||||
pygame.display.set_caption("Горный пейзаж")
|
||||
@@ -26,7 +26,6 @@ def rotate_point(point, center, angle_deg):
|
||||
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)
|
||||
|
||||
@@ -35,19 +34,24 @@ def rotate_point(point, center, angle_deg):
|
||||
def draw_mountain_rotated(surface, color, points, center, angle):
|
||||
"""Рисует повёрнутую гору"""
|
||||
rotated_points = [rotate_point(p, center, angle) for p in points]
|
||||
polygon(surface, color, rotated_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)
|
||||
|
||||
rect(screen, BEIGE, (0, 120, WIDTH, 200)) # Здесь было просто rect, а нужно rect(screen, ...)
|
||||
pygame.draw.rect(screen, BEIGE, (0, 120, WIDTH, 200))
|
||||
|
||||
circle(screen, SUN, (WIDTH//2, 80), 50)
|
||||
pygame.draw.circle(screen, SUN, (WIDTH//2, 80), 50)
|
||||
|
||||
|
||||
rotate_center = (WIDTH//3, 300)
|
||||
|
||||
# Центр поворота для дальнего ряда
|
||||
rotate_center = (WIDTH//2, 400)
|
||||
|
||||
# ВТОРОЙ РЯД - ПОВЁРНУТ НА 10° ПО ЧАСОВОЙ СТРЕЛКЕ
|
||||
far_mountains_points = [
|
||||
(-100, 520), (0, 420), (100, 440), (200, 400), (300, 430),
|
||||
(400, 390), (500, 420), (600, 380), (700, 410), (800, 370),
|
||||
@@ -57,23 +61,16 @@ far_mountains_points = [
|
||||
|
||||
draw_mountain_rotated(screen, MOUNTAINS_FAR, far_mountains_points, rotate_center, 10)
|
||||
|
||||
# БЛИЖНИЙ РЯД
|
||||
polygon(screen, MOUNTAINS_NEAR,
|
||||
|
||||
|
||||
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)])
|
||||
|
||||
rect(screen, GROUND, (0, HEIGHT-165, WIDTH, 1000))
|
||||
pygame.draw.rect(screen, GROUND, (0, HEIGHT-165, WIDTH, 1000))
|
||||
|
||||
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.display.flip()
|
||||
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
Reference in New Issue
Block a user