Текущая ветка: main

Начальный коммит

 Изменения, которые будут включены в коммит:
	новый файл:    1_draw.py
	новый файл:    eg.py
This commit is contained in:
2026-03-17 16:51:05 +03:00
commit 35a5fa510c
2 changed files with 102 additions and 0 deletions

65
1_draw.py Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
# Проверка наличия Python и pygame
if ! command -v python3 &> /dev/null; then
echo "Ошибка: Python3 не установлен"
exit 1
fi
# Проверка наличия pygame
if ! python3 -c "import pygame" 2>/dev/null; then
echo "Ошибка: pygame не установлен"
echo "Установите его командой: pip install pygame"
exit 1
fi
# Создаем временный Python файл
TEMP_FILE=$(mktemp --suffix=.py)
# Записываем код во временный файл
cat > "$TEMP_FILE" << 'EOF'
import pygame
from pygame.draw import *
pygame.init()
FPS = 30
screen = pygame.display.set_mode((400, 400))
# Рисование фигур
rect(screen, (255, 0, 255), (100, 100, 200, 200))
rect(screen, (0, 0, 255), (100, 100, 200, 200), 5)
polygon(screen, (255, 255, 0), [(100,100), (200,50),
(300,100), (100,100)])
polygon(screen, (0, 0, 255), [(100,100), (200,50),
(300,100), (100,100)], 5)
circle(screen, (0, 255, 0), (200, 175), 50)
circle(screen, (255, 255, 255), (200, 175), 50, 5)
pygame.display.update()
clock = pygame.time.Clock()
finished = False
print("Рисование завершено. Нажмите любую клавишу для выхода...")
while not finished:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
finished = True
elif event.type == pygame.KEYDOWN:
finished = True
elif event.type == pygame.MOUSEBUTTONDOWN:
finished = True
pygame.quit()
EOF
# Запускаем Python скрипт
echo "Запуск PyGame приложения..."
python3 "$TEMP_FILE"
# Удаляем временный файл
rm "$TEMP_FILE"
echo "Программа завершена"

37
eg.py Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env python3
import pygame
from pygame.draw import *
pygame.init()
FPS = 30
screen = pygame.display.set_mode((800, 500))
def pezag(screen):
# Небо
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)])
# передний слой
rect(screen, (170, 130, 140), (0, 380, 800, 120))
# Вызов функции отрисовки
pezag(screen)
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()