Commits

César Bustíos committed 84a609c

Avoid clicking boxes and options while in the new_game process

Comments (0)

Files changed (1)

     pygame.event.set_blocked(pygame.MOUSEMOTION)
 
     while running:
-        # New board?
-        if new_game:
-            board = generate_board(False)
-            new_game = False
-
         # Background image
         SCREEN.blit(BACKGROUND_IMG, (0, 0))
         draw_table(WHITE, BLACK)
-
         draw_board(board, box_img)
 
         # Display options: New game, Quit, Sound, etc.
         options = display_game_options_and_score(str(score))
 
+        # New board?
+        if new_game:
+            board = generate_board(False)
+            display_new_game_settings('mk.ttf')
+            #~ new_game = False
+
         clicked = False
         pygame.display.update()
 
                 x, y = event.pos
                 clicked = True
 
-        if clicked:
+        if clicked and new_game is not True:
             # New game?
             if options['new_game'].collidepoint(x, y):
                 new_game = True
 
         # Get box at pixel (x,y)
         row, col = get_box(board, x, y)
-
-        if row != None and col != None:
+        if row != None and col != None and new_game is not True:
             # Box is clicked
             if not board['revealed'][row][col] and clicked:
                 reveal_box(board, row, col, box_img)
         if all_matched(board['revealed']):
             display_game_over_message('mk.ttf')
 
-        # New board?
-        if new_game:
-            board = generate_board(False)
-            display_new_game_settings('mk.ttf')
-            #~ new_game = False
-
-        pygame.display.update()
-
     pygame.quit()