import pygame
import sys
def lines(dot):
hor=set()
diag1=set()
diag2=set()
vert=set()
hor.add(dot)
diag1.add(dot)
diag2.add(dot)
vert.add(dot)
flag=True
n=1
if1=True
if2=True
while flag:
if (dot[0]-n,dot[1]) in dots and if1:
hor.add((dot[0]-n,dot[1]))
else:
if1=False
if (dot[0]+n,dot[1]) in dots and if2:
hor.add((dot[0]+n,dot[1]))
else:
if2=False
if (dot[0]-n,dot[1]) not in dots and (dot[0]+n,dot[1]) not in dots:
flag=False
n+=1
flag=True
n=1
if1=True
if2=True
while flag:
if (dot[0],dot[1]-n) in dots and if1:
vert.add((dot[0],dot[1]-n))
else:
if1=False
if (dot[0],dot[1]+n) in dots and if2:
vert.add((dot[0],dot[1]+n))
else:
if2=False
if (dot[0],dot[1]-n) not in dots and (dot[0],dot[1]+n) not in dots:
flag=False
n+=1
flag=True
n=1
if1=True
if2=True
while flag:
if (dot[0]+n,dot[1]+n) in dots and if1:
diag1.add((dot[0]+n,dot[1]+n))
else:
if1=False
if (dot[0]-n,dot[1]-n) in dots and if2:
diag1.add((dot[0]-n,dot[1]-n))
else:
if2=False
if (dot[0]-n,dot[1]-n) not in dots and (dot[0]+n,dot[1]+n) not in dots:
flag=False
n+=1
flag=True
n=1
if1=True
if2=True
while flag:
if (dot[0]+n,dot[1]-n) in dots and if1:
diag2.add((dot[0]+n,dot[1]-n))
else:
if1=False
if (dot[0]-n,dot[1]+n) in dots and if2:
diag2.add((dot[0]-n,dot[1]+n))
else:
if2=False
if (dot[0]+n,dot[1]-n) not in dots and (dot[0]-n,dot[1]+n) not in dots:
flag=False
n+=1
return hor,diag1,diag2,vert
dots=set()
screen=pygame.display.set_mode((800,800))
while True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit
sys.exit()
if event.type==pygame.MOUSEBUTTONDOWN:
x,y=event.pos
pygame.draw.circle(screen,(255,255,255),(x//60*60+17,y//60*60+17),30)
dots.add((x//60,y//60))
pygame.display.flip()
print(lines((x//60,y//60)))
for line in lines((x//60,y//60)):
if len(line)>=6:
line=list(line)
for l in range(5):
print(line)
pygame.draw.line(screen,(255,0,0),(line[l][0]*60+17,line[l][1]*60+17),(line[l+1][0]*60+17,line[l+1][1]*60+17),2)
pygame.display.flip()