import pygame
import random
WIDTH = 500
HEIGHT = 500
FPS = 25
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
speedX = 0
running = True
state = []
for index in range(0,400,1):
state.append(1)
index = 0
indexY = 475
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill(BLACK)
counter = 0
for it_1 in range(0,500,25):
for it_2 in range(0,500,25):
if (state[counter]==1):
pygame.draw.rect(screen,WHITE, (it_1,it_2,24,24))
if (state[counter]==2):
pygame.draw.rect(screen,RED, (it_1,it_2,24,24))
counter = counter + 1
pygame.draw.rect(screen,RED, (speedX,speedY,24,24))
pygame.display.flip()
speedY = speedY + 25
if speedY > indexY:
state[19*index +(index-1) + (20-index)] = 2
speedY = 0
speedX = speedX + 25
index = index + 1
indexY = indexY - 25
if (indexY == -25):
indexY = 475
speedX = 0
if (index == 20): index = 0
pygame.quit()
|