Esempio n. 1
0
screen = pygame.display.set_mode((300, 300))  # creates the screen
background = pygame.Surface((300, 300))  # creates the background image
background = background.convert()
board = pygame.Surface((300, 300))
pygame.draw.rect(background, WHITE, [50, 50, 201, 201])
draw_lines()
screen.blit(background, (0, 0))  # blits background onto screen
pygame.display.flip()  # updates display
symbols = Symbols()
symbol = Symbol()


while not end:
    for event in pygame.event.get():  # deteremines which key is pressed
        if event.type == pygame.QUIT:  # if you click the quit :(
            end = True  # breaks the while loop
        if event.type == pygame.MOUSEBUTTONDOWN:
            mouse_pos = pygame.mouse.get_pos()
            mx = mouse_pos[0]
            my = mouse_pos[1]
            if 50 <= mx <= 251 and 50 <= my <= 251:
                grid_pos = (get_pos(mx), get_pos(my))
                if occupied_check(symbols, grid_pos):
                    symbol.add(grid_pos)
                    draw_symbol(symbol)
                    symbols.add(symbol)
                    symbol.switch()
                # print("line check", symbols.line_check(symbol))
                # print(grid_pos)