import pygame import sys # Initialize Pygame pygame.init() # Set up display WIDTH, HEIGHT = 800, 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Rat in Pygame") # Colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) # Rat properties rat_width = 40 rat_height = 40 rat_color = (139, 69, 19) # Brown color for rat # Rat class class Rat(pygame.sprite.Sprite): def __init__(self): super().__init__() self.image = pygame.Surface((rat_width, rat_height)) self.image.fill(rat_color) self.rect = self.image.get_rect() self.rect.center = (WIDTH // 2, HEIGHT // 2) def update(self): pass # Create rat object rat = Rat() # Group for sprites all_sprites = pygame.sprite.Group() all_sprites.add(rat) # Main loop running = True while running: # Event handling for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # Update all_sprites.update() # Render screen.fill(WHITE) all_sprites.draw(screen) pygame.display.flip() # Cap the frame rate pygame.time.Clock().tick(60) pygame.quit() sys.exit()