Commits

César Bustíos committed 7f0718e

Always start with new_game=True. Adding image background for new game options. display_new_game_settings handles the process

  • Participants
  • Parent commits 17b1dfe
  • Branches new_game

Comments (0)

Files changed (2)

File data/images/new_game_bg.png

Added
New image

File src/memory.py

     pygame.display.set_caption('Geezle - Memory Puzzle')
 
     board = generate_board(False)
-    new_game = False
+    new_game = True
     box_img = BOX_IMG
 
     # Number of moves
     first_choice = None
 
     while True:
-        # New board?
-        if new_game:
-            board = generate_board(False)
-            new_game = False
-
         # Background image
         SCREEN.blit(BACKGROUND_IMG, (0, 0))
         draw_table(WHITE, BLACK)
         # Display options: New game, Quit, Sound, etc.
         options = display_game_options_and_score(str(score))
 
-        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:
             # Mouse is over a box
             if not board['revealed'][row][col]:
                 highlight_box(board, row, col)
         if all_matched(board['revealed']):
             display_game_over_message('mk.ttf')
 
+        # New board?
+        if new_game:
+            board = generate_board(False)
+            display_new_game_settings()
+            #~ new_game = False
+
         pygame.display.update()
         CLOCK.tick(FPS)
 
     return box_rects
 
 
+def display_new_game_settings():
+    """
+    For choosing icons theme
+    """
+    # Temporal surface for transparency
+    tmp_surface = pygame.Surface(SCREEN_RESOLUTION)
+    tmp_surface.set_alpha(100)
+    tmp_surface.fill((0,0,0))
+    SCREEN.blit(tmp_surface, (0,0))
+
+    # Background image for holding new game options
+    img_path = join(IMAGES_PATH, 'new_game_bg.png')
+    new_game_img = pygame.image.load(img_path).convert()
+
+    # Get the image rect and set position on the screen
+    new_game_rect = new_game_img.get_rect()
+    new_game_rect.left = 0
+    new_game_rect.top = (SCREEN_RESOLUTION[1] / 2) - (new_game_img.get_height() / 2)
+
+    SCREEN.blit(new_game_img, new_game_rect)
+
+
 def reveal_box(board, row, col, box_img):
     """
     Revealed a box when it is clicked