import pygame import random # Initialize Pygame pygame.init() # Screen settings WIDTH, HEIGHT = 1900, 1000 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("DVD Logo Bouncing") # Colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) # Load assets dvd_logo = pygame.image.load("Brr Brr pat.png").convert_alpha() dvd1_logo = pygame.image.load("Tralala.png").convert_alpha() corner_sound = pygame.mixer.Sound("E.wav") # Load sound # Get sizes logo_width, logo_height = dvd_logo.get_size() logo1_width, logo1_height = dvd1_logo.get_size() # Initial positions and speeds x, y = random.randint(0, WIDTH - logo_width), random.randint(0, HEIGHT - logo_height) x1, y1 = random.randint(0, WIDTH - logo1_width), random.randint(0, HEIGHT - logo1_height) speed_x, speed_y = 3, 3 speed_x1, speed_y1 = 3, 3 # Clock clock = pygame.time.Clock() running = True while running: corner_hit = False # Track corner collisions # Move and bounce first logo x += speed_x y += speed_y hit_x = x <= 0 or x + logo_width >= WIDTH hit_y = y <= 0 or y + logo_height >= HEIGHT if hit_x: speed_x *= -1 if hit_y: speed_y *= -1 if hit_x and hit_y: corner_hit = True # Move and bounce second logo x1 += speed_x1 y1 += speed_y1 hit_x1 = x1 <= 0 or x1 + logo1_width >= WIDTH hit_y1 = y1 <= 0 or y1 + logo1_height >= HEIGHT if hit_x1: speed_x1 *= -1 if hit_y1: speed_y1 *= -1 if hit_x1 and hit_y1: corner_hit = True # Handle corner hit event if corner_hit: screen.fill(WHITE) pygame.display.flip() pygame.mixer.Sound.play(corner_sound) pygame.time.delay(300) # Flash duration # Draw normally screen.fill(BLACK) screen.blit(dvd_logo, (x, y)) screen.blit(dvd1_logo, (x1, y1)) # Event handling for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: pygame.quit() sys.exit() pygame.display.flip() clock.tick(60) pygame.quit()