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))
f1 = pygame.font.Font(None, 36)
running = True
clock = pygame.time.Clock()
x1 = WIDTH/2
y1 = HEIGHT/2
while running:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
for it_1 in range(0,500,50):
for it_2 in range(0,500,50):
pygame.draw.rect(screen,WHITE, (it_1,it_2,49,49))
pygame.draw.rect(screen,RED, (x1,y1,49,49))
select = random.randint(0,3)
if (select == 0):
x1 = x1 - 1
if (select == 1):
x1 = x1 + 1
if (select == 2):
y1 = y1 - 1
if (select == 3):
y1 = y1 + 1
pygame.display.update()
pygame.quit()
|