import pygame
import sys
import random
pygame.init()
sc = pygame.display.set_mode((500, 500))
sc.fill((0, 0, 0))
color1 =(random.randint(0,255),random.randint(0,255),random.randint(0,255))
color2 =(random.randint(0,255),random.randint(0,255),random.randint(0,255))
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
pygame.image.save(sc, "image.jpg")
color1 =(random.randint(0,255),random.randint(0,255),random.randint(0,255))
color2 =(random.randint(0,255),random.randint(0,255),random.randint(0,255))
for x in range(10):
for y in range(10):
if (x + y) % 4 == 0:
pygame.draw.rect(sc,color1,(50*x,50*y,50,50))
else:
pygame.draw.rect(sc,color2,(50*x,50*y,50,50))
pygame.display.update()
|