Use all coordinates in grid [python]
<p>For a minesweeper I have created a board using python and pygame.
If you click a bomb, you should see the entire board. I have separate functions that contain the (randomised) bomb positions, and create the numbers around the bombs(on the proper coordinates). How do I make sure it checks the coordinates 0 to GRID_TILES(the maximum range).</p>

<p>This is how I show the 'clicked' coordinates</p>

<pre><code>def handle_mouse(mousepos):
    x, y = mousepos
    x, y = math.ceil(x / 40), math.ceil(y / 40)
    check = x, y
    if check in FLAGS:
        print("You have to unflag this tile before clicking!")
    else:
        CLICKED.append(check)
        draw_item(CELLS[x -1][y - 1], x - 1, y - 1, check)
    bomb_check(check)

def draw_item(item, x, y, check):
    global BLOCK_SIZE, screen
    background = pygame.image.load("img/white.png")
    if check in BOMBS:
        image = pygame.image.load("img/9.png")
    else:
        image = pygame.image.load("img/"+str(item)+".png")
    x, y = x * BLOCK_SIZE, y * BLOCK_SIZE
    screen.blit(background, (x, y))
    screen.blit(image, (x + 10, y + 10))
    pygame.display.flip()
</code></pre>

<p>Using:</p>

<pre><code>def game_mainloop():
    While True:
        if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
            handle_mouse(pygame.mouse.get_pos())
        if event.type == pygame.MOUSEBUTTONDOWN and event.button == 3:
            handle_flag(pygame.mouse.get_pos())
</code></pre>

<p>The following definitions are:</p>

<p>CELLS = list of number of bombs adjecent to a tile</p>

<p>FLAGS = a list of the flagged positions</p>

<p>CLICKED = a list of clicked positions</p>

<p>bomb_check = handles if the clicked coordinate is a bomb</p>

<p>I have imported both pygame and math.</p>

<p>As of now, the code now just opens up the tile you click, but I want to know how to get another line of code to open up every tile in the grid</p>

<p>I got the solution:</p>

<pre><code>def show_board():
for x in range(0,GRID_TILES):
    for y in range(0, GRID_TILES):
        draw_item(CELLS[x][y], x, y, (x+1,y+1))
</code></pre>

<p>If I call this after hitting a bomb, it will show the entire board.
If I just wanted to use every single coordinate on a grid, just</p>

<pre><code>def show_board():
for x in range(0,GRID_TILES):
    for y in range(0, GRID_TILES):
</code></pre>

<p>is sufficient.</p>

python python-3.x pygame