import pygame
pygame.init()
clock = pygame.time.Clock()
window = pygame.display.set_mode((1280, 720))
runned = True
color_bg = 0
pygame.display.set_caption('My Game')
icon = pygame.image.load('png/icon.png')
bg = pygame.image.load('png/bg.jpg')
pygame.display.set_icon(icon)
player = pygame.image.load('png/right/1.png')
player_anim_count = 1
while runned:
window.fill((0, 0, 0))
window.blit(bg, (0,0))
if player_anim_count == 2:
player = pygame.image.load('png/right/2.png')
elif player_anim_count == 3:
player = pygame.image.load('png/right/3.png')
elif player_anim_count == 4:
player = pygame.image.load('png/right/4.png')
window.blit(player, (250,475))
if player_anim_count == 4:
player_anim_count = 1
else:
player_anim_count += 1
pygame.display.flip()
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
runned = False
pygame.quit()
попробуй так import pygame
pygame.init()
flags = pygame.DOUBLEBUF | pygame.RESIZABLE
window = pygame.display.set_mode((1280, 720), flags)
clock = pygame.time.Clock()
pygame.display.set_caption('My Game')
icon = pygame.image.load('png/icon.png')
pygame.display.set_icon(icon)
bg = pygame.image.load('png/bg.jpg').convert()
player_images = [pygame.image.load(f'png/right/{i}.png').convert_alpha() for i in range(1, 5)]
player_anim_count = 0
WHITE = (255, 255, 255)
font = pygame.font.Font(None, 36)
runned = True
while runned:
for event in pygame.event.get():
if event.type == pygame.QUIT:
runned = False
window.blit(bg, (0, 0))
shadow_offset = (5, 5)
shadow_color = (0, 0, 0, 128)
shadow_rect = player_images[player_anim_count].get_rect(topleft=(250 + shadow_offset[0], 475 + shadow_offset[1]))
pygame.draw.rect(window, shadow_color, shadow_rect)
window.blit(player_images[player_anim_count], (250, 475))
player_anim_count = (player_anim_count + 1) % len(player_images)
text_surface = font.render("Анимация игрока", True, WHITE)
window.blit(text_surface, (10, 10))
pygame.display.flip()
clock.tick(30)
pygame.quit()