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
screen.fill(BLACK)
counter = 0
for it_1 in range(0,500,100):
for it_2 in range(0,500,100):
pygame.draw.rect(screen,WHITE, (it_1,it_2,99,99))
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
x, y = pygame.mouse.get_pos()
x = x//100 * 100
y = y//100 * 100
font = pygame.font.SysFont(None, 24)
img = font.render(str(counter), True, BLACK)
screen.blit(img, (x+49, y+49))
counter = counter + 1
pygame.display.update()
pygame.quit()
|