import pygame
import random
import math
pygame.init()
win = pygame.display.set_mode((500,500))
pygame.display.set_caption("")
run = True
x = random.randint(50,450)
y = 0
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
pygame.image.save(win, "image.jpg")
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
print(pos[0])
print(pos[1])
if (pos[0] > x and pos[0] < x+50 and pos[1] < y+250):
print("hello")
x = random.randint(50,450)
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
win.fill((0,0,0))
pygame.draw.rect(win, (r, g, b), (x, y, 50, 50))
pos = pygame.mouse.get_pos()
pygame.draw.circle(win, (255,255,255),(pos[0],pos[1]-200), 5)
pygame.draw.circle(win, (255,255,255),(pos[0],pos[1]), 5)
pygame.display.update()
pygame.quit()
|