import pygame
import random
WIDTH = 500
HEIGHT = 500
FPS = 60
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
speedY = 0
selectfigure = random.randint(1,4)
running = True
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
speedY = speedY + 5
screen.fill(BLACK)
if selectfigure == 1:
pygame.draw.rect(screen,RED, (250,speedY,20,20))
if selectfigure == 2:
pygame.draw.rect(screen,RED, (250,speedY,20,20))
pygame.draw.rect(screen,GREEN,(250,speedY+20,20,20))
if selectfigure == 3:
pygame.draw.rect(screen,RED, (250,speedY,20,20))
pygame.draw.rect(screen,GREEN,(250,speedY+20,20,20))
pygame.draw.rect(screen,BLUE,(250,speedY+40,20,20))
if selectfigure == 4:
pygame.draw.rect(screen,RED, (250,speedY,20,20))
pygame.draw.rect(screen,GREEN,(250,speedY+20,20,20))
pygame.draw.rect(screen,BLUE,(250,speedY+40,20,20))
pygame.draw.rect(screen,WHITE,(250,speedY+60,20,20))
pygame.display.flip()
if speedY > 475:
speedY = 0
selectfigure = random.randint(1,4)
pygame.quit()
|