Commits

César Bustíos  committed 4b8b9b6

Missing convert() and convert_alpha() in some images

  • Participants
  • Parent commits 74072c9

Comments (0)

Files changed (1)

File src/memory.py

 GOLD = (205, 180, 12)
 HIGHLIGHT_COLOR = BLUE
 
-# Images
-BOX_IMG = pygame.image.load(join(IMAGES_PATH, 'box1.png'))
-BACKGROUND_IMG = pygame.image.load(BACKGROUND_IMG_PATH)
-
 pygame.init()
 SCREEN = pygame.display.set_mode(SCREEN_RESOLUTION)
 CLOCK = pygame.time.Clock()
 
+# Images
+BOX_IMG = pygame.image.load(join(IMAGES_PATH, 'box1.png')).convert()
+BACKGROUND_IMG = pygame.image.load(BACKGROUND_IMG_PATH).convert()
+
 # Loading and playing background music:
 pygame.mixer.music.load(BACKGROUND_MUSIC_PATH)
 pygame.mixer.music.play(-1, 0.0)
                 pygame.quit()
                 sys.exit()
             elif options['blue_box'].collidepoint(x, y):
-                box_img = pygame.image.load(join(IMAGES_PATH, 'box1.png'))
+                path = join(IMAGES_PATH, 'box1.png')
+                box_img = pygame.image.load(path).convert()
             elif options['green_box'].collidepoint(x, y):
-                box_img = pygame.image.load(join(IMAGES_PATH, 'box2.png'))
+                path = join(IMAGES_PATH, 'box2.png')
+                box_img = pygame.image.load(path).convert()
             elif options['purple_box'].collidepoint(x, y):
-                box_img = pygame.image.load(join(IMAGES_PATH, 'box3.png'))
+                path = join(IMAGES_PATH, 'box3.png')
+                box_img = pygame.image.load(path).convert()
             elif options['tux_box'].collidepoint(x, y):
-                box_img = pygame.image.load(join(IMAGES_PATH, 'box4.png'))
+                path = join(IMAGES_PATH, 'box4.png')
+                box_img = pygame.image.load(path).convert_alpha()
 
         # Get box at pixel (x,y)
         row, col = get_box(board, x, y)
     y = 95
 
     # Buttons
-    new_game_surface = pygame.image.load(join(IMAGES_PATH, 'buttons/new_game.png'))
-    quit_surface = pygame.image.load(join(IMAGES_PATH, 'buttons/quit.png'))
+    new_game_surface = pygame.image.load(join(IMAGES_PATH, 'buttons/new_game.png')).convert()
+    quit_surface = pygame.image.load(join(IMAGES_PATH, 'buttons/quit.png')).convert()
 
     # Rects
     new_game_rect = new_game_surface.get_rect()
     SCREEN.blit(option_surface, option_rect)
 
     # Surfaces
-    box1_surface = pygame.image.load(join(IMAGES_PATH, 'box1_thumb.png'))
-    box2_surface = pygame.image.load(join(IMAGES_PATH, 'box2_thumb.png'))
-    box3_surface = pygame.image.load(join(IMAGES_PATH, 'box3_thumb.png'))
-    box4_surface = pygame.image.load(join(IMAGES_PATH, 'box4_thumb.png'))
+    box1_surface = pygame.image.load(join(IMAGES_PATH, 'box1_thumb.png')).convert()
+    box2_surface = pygame.image.load(join(IMAGES_PATH, 'box2_thumb.png')).convert()
+    box3_surface = pygame.image.load(join(IMAGES_PATH, 'box3_thumb.png')).convert()
+    box4_surface = pygame.image.load(join(IMAGES_PATH, 'box4_thumb.png')).convert_alpha()
 
     # Rects
     box1_rect = box1_surface.get_rect()