import pygame
WHITE = (255, 255, 255)
RED = (225, 0, 50)
GREEN = (0, 225, 0)
BLUE = (0, 0, 225)
x = 0
y = 0
process = 0
state = 0
pygame.init()
sc = pygame.display.set_mode((800,800))
sc.fill(WHITE)
pygame.draw.rect(sc,RED, pygame.Rect(x,y,25,25))
pygame.display.flip()
while 1:
for i in pygame.event.get():
if i.type == pygame.QUIT:
exit()
if (i.type == pygame.MOUSEBUTTONDOWN): process = 1
if (i.type == pygame.MOUSEMOTION):
x = 0
y = 0
process = 0
pressed = pygame.mouse.get_pressed()
pos = pygame.mouse.get_pos()
if (process == 1):
sc.fill(WHITE)
pygame.draw.rect(sc,RED, pygame.Rect(x,y,25,25))
pygame.display.flip()
if (x+25 <= pos[0]): x += 1
if (y+25 <= pos[1]): y += 1
if (x > pos[0]+25):
state = state + 1
if (y > pos[1]+25):
state = state + 1
if (state == 2):
state = 0
process = 0
x = 0
y = 0
|