import pygame # Initialize the pygame module pygame.init() # Load the sprite sheet sprite_sheet = pygame.image.load("Knight_Die_dir1.png") # Define the size of each frame frame_width = 64 frame_height = 64 # Calculate the number of frames in the sprite sheet num_frames = sprite_sheet.get_width() // frame_width # Split the sprite sheet into individual frames frames = [sprite_sheet.subsurface((i*frame_width, 0, frame_width, frame_height)) for i in range(num_frames)] # Create a window screen = pygame.display.set_mode((800, 600)) # Frame counter current_frame = 0 # Main loop running = True while running: # Event handling for event in pygame.event.get(): if event.type == pygame.QUIT: running = False break # Draw the current frame screen.blit(frames[current_frame], (0, 0)) # Advance to the next frame current_frame = (current_frame + 1) % num_frames # Update the display pygame.display.flip() # Delay to control the speed of the animation pygame.time.delay(100) pygame.quit()