После просмотра видео получился следующий код.Не знаю,писал ли я уже такое.
import pygame
import sys
FPS = 60
WIDTH = 800
HEIGHT = 600
WHITE = (255, 255, 255)
ORANGE = (255, 150, 100)
clock = pygame.time.Clock()
sc = pygame.display.set_mode((WIDTH,HEIGHT))
x = WIDTH/2
y = HEIGHT/2
state = 10
r = 25
sc.fill(WHITE)
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
state = 50
if event.type == pygame.MOUSEBUTTONUP:
state = 10
if event.type == pygame.MOUSEMOTION:
if state == 50:
mouse_x, mouse_y = event.pos
pygame.draw.circle(sc, ORANGE, (mouse_x, mouse_y),r)
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
pygame.image.save(sc, "image.jpg")
pygame.display.update()
clock.tick(FPS)
|