pos = pygame.mouse.get_pos() if pos[0] > (cell_len + margin) * size or pos[1] > (cell_len + margin) * size: continue col = int(pos[0] // (cell_len + margin)) row = int(pos[1] // (cell_len + margin)) # print('Click {}. Grid coordinates {}, {}'.format(pos, row, col)) # condition for opening if initialise and left_click == 1: board.create_board(row, col) # created board object # make_text('Remaining: {}'.format(board.remaining), x/2, y - cell_len/2, white) initialise = False board.print_board() # normal play starts here if not initialise: # define cell for clicked cell cell = board.cell_board[row][col] # calling methods based on player choice if left_click == 1 and not cell.flagged(): if not cell.opened(): board.open_cell(row, col) else: board.open_neighbours(row, col) elif right_click == 1 and not cell.opened():