import pygame import sys import random # Initialize Pygame pygame.init() # Get the screen dimensions SCREEN_WIDTH, SCREEN_HEIGHT = pygame.display.list_modes()[0] # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) GREEN = (0, 255, 0) class Raindrop(pygame.sprite.Sprite): def __init__(self): super().__init__() self.font = pygame.font.Font(None, 20) self.image = self.font.render(random.choice(['1', '0']), True, GREEN) # Change the color to green self.rect = self.image.get_rect() self.rect.x = random.randrange(SCREEN_WIDTH) self.rect.y = random.randrange(-20, -5) def update(self): self.rect.y += random.randint(5, 15) if self.rect.y > SCREEN_HEIGHT: self.rect.y = random.randrange(-20, -5) self.rect.x = random.randrange(SCREEN_WIDTH) self.image = self.font.render(random.choice(['1', '0']), True, GREEN) # Change the color to green def main(): screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), pygame.FULLSCREEN) # Set fullscreen mode pygame.display.set_caption("Rain Game") all_sprites = pygame.sprite.Group() for _ in range(300): # Increase the number of raindrops raindrop = Raindrop() all_sprites.add(raindrop) clock = pygame.time.Clock() running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() sys.exit() all_sprites.update() screen.fill(BLACK) # Change the background color to black all_sprites.draw(screen) pygame.display.flip() clock.tick(65) # Adjust the argument to control the speed (higher is slower) if __name__ == "__main__": main()