我已为左右角色设置了动画,如何在不使所有人同时发抖的情况下为左右站立设置动画? pygame

因此,如果我要向右偏,这会给我的角色添加动画,但如果我向左偏,则会使这个动画但是 当我不向右移动右边的动画和左边的动画时,我该如何做呢?

I managed to do it for my right side but idk why my left side isnt working VIDEO

    def draw(self):
        self.rect.topleft = (self.x,self.y)

        if self.direction == "left":
            self.clock.tick(self.fps)
            player_image = self.lefts[self.anim_index]
            self.anim_index += 1
            if self.anim_index == len(self.lefts):
                self.anim_index = 0
        elif self.direction != "left":
            player_image = self.standingleft[self.anim_index]
            self.anim_index += 1
            if self.anim_index == len(self.standingleft):
                self.anim_index = 0

        if self.direction == "right":
            player_image = self.rights[self.anim_index]
            self.anim_index += 1
            if self.anim_index == len(self.rights):
                self.anim_index = 0
        elif self.direction == "standright":
            player_image = self.standingright[self.anim_index]
            self.anim_index += 1
            if self.anim_index == len(self.standingright):
                self.anim_index = 0



我的球员班

# player class

class player:
    def __init__(self,x,y,height,width,color):
        self.x = x
        self.y = y
        self.color = color
        self.height  = height
        self.width = width
        self.speed = 5
        self.isJump = False
        self.JumpCount = 10
        self.fall = 0
        #hit box
        self.hitbox = (self.x + 20, self.y, 28, 60)
        self.stand = pygame.image.load("stands.png")
        self.rights = [pygame.image.load("L1.png"),
        pygame.image.load("L2.png"),
        pygame.image.load("L3.png"),
        pygame.image.load("L4.png"),
        pygame.image.load("L5.png"),
        pygame.image.load("L6.png"),
        pygame.image.load("L7.png"),
        pygame.image.load("L8.png"),
        pygame.image.load("L9.png"),
        pygame.image.load("L10.png"),
        pygame.image.load("L11.png"),
        pygame.image.load("L12.png"),
        pygame.image.load("L13.png"),
        pygame.image.load("L14.png"),
        pygame.image.load("L15.png")]
        self.fps = 50
        self.clock = pygame.time.Clock()
        self.lefts = [pygame.image.load("e1.png"),
        pygame.image.load("e2.png"),
        pygame.image.load("e3.png"),
        pygame.image.load("e4.png"),
        pygame.image.load("e5.png"),
        pygame.image.load("e6.png"),
        pygame.image.load("e7.png"),
        pygame.image.load("e8.png"),
        pygame.image.load("e9.png"),
        pygame.image.load("e10.png"),
        pygame.image.load("e11.png"),
        pygame.image.load("e12.png"),
        pygame.image.load("e13.png"),
        pygame.image.load("e14.png"),
        pygame.image.load("e15.png")]
        self.standingright = [pygame.image.load("d1.png"),
                pygame.image.load("d2.png"),
                pygame.image.load("d3.png"),
                pygame.image.load("d4.png"),
                pygame.image.load("d5.png"),
                pygame.image.load("d6.png"),
                pygame.image.load("d7.png"),
                pygame.image.load("d8.png"),
                pygame.image.load("d9.png"),
                pygame.image.load("d10.png"),
                pygame.image.load("d11.png"),
                pygame.image.load("d12.png"),
                pygame.image.load("d13.png"),
                pygame.image.load("d14.png"),
                pygame.image.load("d15.png")]
        self.standingleft =[pygame.image.load("s1.png"),
            pygame.image.load("s2.png"),
            pygame.image.load("s3.png"),
            pygame.image.load("s4.png"),
            pygame.image.load("s5.png"),
            pygame.image.load("s6.png"),
            pygame.image.load("s7.png"),
            pygame.image.load("s8.png"),
            pygame.image.load("s9.png"),
            pygame.image.load("s10.png"),
            pygame.image.load("s11.png"),
            pygame.image.load("s12.png"),
            pygame.image.load("s13.png"),
            pygame.image.load("s14.png"),
            pygame.image.load("s15.png")]
        self.rights = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.rights]
        self.lefts = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.lefts]
        self.standingright = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.standingright]
        self.standingleft = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.standingleft]
        self.bo_index = 0
        self.start_time = pygame.time.get_ticks()
        self.anim_fps = 400
        self.anim_index = 0
        self.stans_index = 0
        self.direction = "right"
        self.direction = "left"
        self.direction = "standright"

        self.rect = pygame.rect = pygame.Rect(self.x,self.y,width, height)
    def draw(self):
        self.rect.topleft = (self.x,self.y)

        if self.direction == "left":
            self.clock.tick(self.fps)
            player_image = self.lefts[self.anim_index]
            self.anim_index += 1
            if self.anim_index == len(self.lefts):
                self.anim_index = 0
        elif self.direction != "left":
            player_image = self.standingleft[self.anim_index]
            self.anim_index += 1
            if self.anim_index == len(self.standingleft):
                self.anim_index = 0

        if self.direction == "right":
            player_image = self.rights[self.anim_index]
            self.anim_index += 1
            if self.anim_index == len(self.rights):
                self.anim_index = 0
        elif self.direction == "standright":
            player_image = self.standingright[self.anim_index]
            self.anim_index += 1
            if self.anim_index == len(self.standingright):
                self.anim_index = 0