Commits

César Bustíos  committed 0a2f30c

Bigger screen, different background image. Added background music and reveal box sound

  • Participants
  • Parent commits cd4da7f

Comments (0)

Files changed (4)

File data/images/memory_background.jpg

Old
Old image
New
New image

File data/sounds/memory_music.mp3

Binary file added.

File data/sounds/reveal_box.wav

Binary file added.
 PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
 IMAGES_DIR = os.path.join(PROJECT_DIR, 'data/images')
 FONTS_DIR = os.path.join(PROJECT_DIR, 'data/fonts')
+SOUNDS_PATH = os.path.join(PROJECT_DIR, 'data/sounds')
 LOGOS_DIR = os.path.join(IMAGES_DIR, 'logos')
 UNREVEALED_BOX_IMG_PATH = os.path.join(IMAGES_DIR, 'unrevealed_logo1.png')
 BACKGROUND_IMG_PATH = os.path.join(IMAGES_DIR, 'memory_background.jpg')
+BACKGROUND_MUSIC_PATH = os.path.join(SOUNDS_PATH, 'memory_music.mp3')
+
+# Main screen resolution
+SCREEN_RESOLUTION = (800, 600)
 
 # Game and board settings
 WINDOW_WIDTH = 640
 BOARD_HEIGHT = (BOARD_ROWS * BOX_SIZE) + ((BOARD_ROWS - 1) * BOX_GAP)
 IMAGES_NEEDED = (BOARD_COLS * BOARD_ROWS) / 2
 HIGHLIGHT_WIDTH = 3
-X_MARGIN = ((WINDOW_WIDTH - BOARD_WIDTH) / 2)
-Y_MARGIN = ((WINDOW_HEIGHT - BOARD_HEIGHT) / 2)
+X_MARGIN = ((WINDOW_WIDTH - BOARD_WIDTH) / 3)
+Y_MARGIN = ((WINDOW_HEIGHT - BOARD_HEIGHT) / 3)
 OPTION_X_MARGIN = 75
 OPTION_Y_MARGIN = 30
 
 BLACK = (0, 0, 0)
 BLUE = (25, 25, 255)
 GOLD = (205, 180, 12)
-BACKGROUND_COLOR = WHITE
 HIGHLIGHT_COLOR = BLUE
 
 # Images
 BACKGROUND_IMG = pygame.image.load(BACKGROUND_IMG_PATH)
 
 pygame.init()
-MAIN_SURFACE = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
+MAIN_SURFACE = pygame.display.set_mode(SCREEN_RESOLUTION)
 CLOCK = pygame.time.Clock()
 
+# Loading and playing background music:
+pygame.mixer.music.load(BACKGROUND_MUSIC_PATH)
+pygame.mixer.music.play(-1, 0.0)
 
 
 def main():
             board = generate_board(False)
             new_game = False
 
-        # Background image and white table
+        # Background image
         MAIN_SURFACE.blit(BACKGROUND_IMG, (0, 0))
         draw_table(WHITE, BLACK)
 
     if board['revealed'][row][col] == True:
         return
 
+    # Play awesome sound
+    sound_path = os.path.join(SOUNDS_PATH, 'reveal_box.wav')
+    sound = pygame.mixer.Sound(sound_path)
+    sound.play()
+
     animate_unrevealed(rect)
+
     # Mark box as revealed
     board['revealed'][row][col] = True
     MAIN_SURFACE.blit(board['logos'][row][col], (rect.x, rect.y))
 
 
 def draw_table(bg_color, border_color):
-    margin = 10
+    margin = 20
 
     # Position and dimensions
     x = X_MARGIN - margin
     pygame.draw.rect(MAIN_SURFACE, bg_color, (x, y, width, height))
 
     # Table border
-    width = 3
+    width = 5
     point_list = (
         (x, y),
         (x + BOARD_WIDTH + margin * 2, y),