import pygame import sys import random # Initialize Pygame pygame.init() # Screen dimensions SCREEN_WIDTH = 400 SCREEN_HEIGHT = 600 # Create the game window screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption("Flappy Bird with Twitter Pipes") # Load the background image background = pygame.image.load("jimmy-carr.png") # Provide the path to your background image background = pygame.transform.scale(background, (SCREEN_WIDTH, SCREEN_HEIGHT)) # Load the Facebook logo image facebook_logo = pygame.image.load("facebook_logo.png") logo_width = 50 logo_height = 50 facebook_logo = pygame.transform.scale(facebook_logo, (logo_width, logo_height)) # Load the Twitter texture image for pipes twitter_texture = pygame.image.load("twitter_texture.png") # Provide the path to your Twitter texture image twitter_texture = pygame.transform.scale(twitter_texture, (50, SCREEN_HEIGHT)) # Pipe properties pipe_width = 50 pipe_spacing = 200 pipe_gap = 150 pipe_speed = 3 # Bird properties bird_x = 100 bird_y = SCREEN_HEIGHT // 2 bird_speed = 0 gravity = 0.5 jump_force = -8 # List to hold pipes pipes = [] # Add initial pipes for i in range(2): pipe_x = SCREEN_WIDTH + i * pipe_spacing pipe_height = random.randint(100, 400) pipes.append((pipe_x, pipe_height)) # Game loop while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: bird_speed = jump_force # Update bird's position bird_speed += gravity bird_y += bird_speed # Clear the screen screen.blit(background, (0, 0)) # Update and draw pipes for i, (pipe_x, pipe_height) in enumerate(pipes): pipe_x -= pipe_speed pipes[i] = (pipe_x, pipe_height) # Draw top and bottom pipes using the Twitter texture screen.blit(twitter_texture, (pipe_x, 0), (0, 0, pipe_width, pipe_height)) screen.blit(twitter_texture, (pipe_x, pipe_height + pipe_gap), (0, 0, pipe_width, SCREEN_HEIGHT - pipe_height - pipe_gap)) # Check for collision if bird_x + logo_width > pipe_x and bird_x < pipe_x + pipe_width: if bird_y < pipe_height or bird_y + logo_height > pipe_height + pipe_gap: pygame.quit() sys.exit() # Remove off-screen pipes if pipe_x + pipe_width < 0: new_pipe_x = pipes[-1][0] + pipe_spacing new_pipe_height = random.randint(100, 400) pipes.append((new_pipe_x, new_pipe_height)) del pipes[i] # Draw Facebook logo (bird) screen.blit(facebook_logo, (bird_x, bird_y)) # Update the display pygame.display.update() # Cap the frame rate pygame.time.Clock().tick(30)