为什么我的角色同时闪烁两个不同的图像

why is my character bliting two different images at the same time

我正在制作一款游戏,角色会根据他所面对的位置显示枪支动画 这是确定

的代码
class Player(object):

    def __init__(self, x, y, width, height):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.velo = 8
        self.left = False
        self.right = False
        self.walkcount = 0
        self.Idlecount = 0
        self.guncount = 0
        self.gunisfired = False
        self.isIdle = False
        self.standing = True

    def draw(self, screen):
        #draws all the animations to the screen
        if self.walkcount + 1 >= 27:
            self.walkcount = 0
        elif self.Idlecount + 1 >= 27:
            self.Idlecount = 0
        if not(self.standing):
            if self.left:
                screen.blit(walkLeft[self.walkcount//3], (self.x,self.y))
                self.walkcount += 1
                if self.gunisfired == True:
                    if self.guncount//5 >= len(ShootR):
                        self.guncount = 0
                        self.gunisfired == False
                    screen.blit(ShootR[self.guncount//5], (self.x,self.y))
                    self.guncount += 1

            if self.right:
                screen.blit(walkRight[self.walkcount//3], (self.x,self.y))
                self.walkcount += 1
                if self.gunisfired == True:
                    if self.guncount//5 >= len(ShootR):
                        self.guncount = 0
                        self.gunisfired == False
                    screen.blit(ShootR[self.guncount//5], (self.x,self.y))
                    self.guncount += 1
        else:
            if self.left:
                if self.isIdle == True:
                    if self.Idlecount//3 >= len(IdleL):
                        self.Idlecount = 0
                        self.isIdle == False
                    screen.blit(IdleL[self.Idlecount//3], (self.x,self.y))
                    self.Idlecount += 1
                if self.gunisfired == True:
                    if self.guncount//5 >= len(ShootL):
                        self.guncount = 0
                        self.gunisfired == False
                    screen.blit(ShootL[self.guncount//5], (self.x,self.y))
                    self.guncount += 1
            else:
                if self.Idlecount//3 >= len(IdleR):
                    self.Idlecount = 0
                    self.isIdle == False
                screen.blit(IdleR[self.Idlecount//3], (self.x,self.y))
                self.Idlecount += 1
                if self.gunisfired == True:
                    if self.guncount//5 >= len(ShootR):
                        self.guncount = 0
                        self.gunisfired == False
                    screen.blit(ShootR[self.guncount//5], (self.x,self.y))
                    self.guncount += 1

        pygame.display.update()

这里是键盘绑定的代码

man = Player(300, 508, 64, 64)
run = True
while run:
    clock.tick(27)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    keys = pygame.key.get_pressed()

    
    if keys[pygame.K_LEFT] and man.x > man.velo:
        man.x -= man.velo
        man.right = False
        man.left = True
        man.Idlecount = 0
        man.guncount = 0
        man.gunisfired = False
        man.standing = False
    elif keys[pygame.K_RIGHT] and man.x < 600 - man.width - man.velo:
        man.x += man.velo
        man.right = True
        man.left = False
        man.Idlecount = 0
        man.guncount = 0
        man.gunisfired = False
        man.standing = False
    elif keys[pygame.K_SPACE]:
        man.gunisfired = True
        man.isIdle = False
        man.standing = True
        man.Idlecount = 0
    else:
        man.walkcount = 0
        man.isIdle = True
        man.guncount = 0
        man.gunisfired = False
        man.standing = True

问题是枪支图像在他面向左侧时有效,但当它面向右侧时它似乎与空闲动画的第一张图像一起 blit。谁能帮帮我。

if self.isIdle == True 在方法 draw:

的其他情况下丢失
class Player(object):
    # [...]

    def draw(self, screen):
        # [...]

        if not(self.standing):
            # [...]

        else:
            if self.left:
               # [...]

            else:

                if self.isIdle == True:  # <---- this is missing
                    if self.Idlecount//3 >= len(IdleR):
                        self.Idlecount = 0
                        self.isIdle == False
                    screen.blit(IdleR[self.Idlecount//3], (self.x,self.y))
                    self.Idlecount += 1
                if self.gunisfired == True:
                    if self.guncount//5 >= len(ShootR):
                        self.guncount = 0
                        self.gunisfired == False
                    screen.blit(ShootR[self.guncount//5], (self.x,self.y))
                    self.guncount += 1