import pygame import sys pygame.init() # Set up display screen_width, screen_height = 800, 600 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption('Idle Animation Example') # Load idle animation frames idle_frames = [] for i in range(1, 8): # Assuming you have 4 frames named idle1.png, idle2.png, ..., idle4.png filename = f'slime/Slime_{i}.png' img = pygame.image.load(filename).convert_alpha() idle_frames.append(img) frame_rate = 10 # Number of frames per second frame_index = 0 clock = pygame.time.Clock() while True: screen.fill((255, 255, 255)) # Fill the screen with white (or your desired background) # Display current frame current_frame = idle_frames[frame_index] screen.blit(current_frame, (100, 100)) # Adjust coordinates as needed pygame.display.flip() # Update frame index frame_index += 1 if frame_index >= len(idle_frames): frame_index = 0 # Limit frame rate clock.tick(frame_rate) # Event handling for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit()