import pygame
import sys
import random
pygame.init()
sc = pygame.display.set_mode((500, 500))
sc.fill((0, 0, 0))
h = 0
x = 0
y = 0
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
x = event.pos[0]
y = event.pos[1]
pygame.draw.rect(sc, (255, 255, 255), (x,y, 49, 500))
if event.button == 3:
x = event.pos[0]
y = event.pos[1]
pygame.draw.rect(sc, (0, 0, 0), (x,y, 49, 500))
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
select = int(input( "1.Очистить экран \n2.Ввести координаты\n3.Сохранить в файл\n"))
if select == 1:
pygame.draw.rect(sc, (0, 0, 0), (0,0, 500, 500))
if select == 2:
x = input("Введите x-координату ")
y = input("Введите y-координату ")
pygame.draw.rect(sc, (255, 255, 255), (int(x),int(y), 49, 500))
if select == 3:
pygame.image.save(sc, "image.jpg")
pygame.display.update()
|