def update(self, dt, keysDown, screenWidth, screenHeight):
    if self.isRight:
        self.spriteDict = self.spriteRightDict
    elif (not self.isRight):
        self.spriteDict = self.spriteLeftDict
    player1Moves = {'Left': keysDown(pygame.K_a), 'Right': keysDown(pygame.K_d), 'Down': keysDown(pygame.K_s), 'Up': keysDown(pygame.K_w), 'Punch': keysDown(pygame.K_v), 'Kick': keysDown(pygame.K_c), 'Special1': keysDown(pygame.K_SPACE)}
    player2Moves = {'Left': keysDown(pygame.K_LEFT), 'Right': keysDown(pygame.K_RIGHT), 'Down': keysDown(pygame.K_DOWN), 'Up': keysDown(pygame.K_UP), 'Punch': keysDown(pygame.K_l), 'Kick': keysDown(pygame.K_k), 'Special1': keysDown(pygame.K_j)}
    if (self.player == 1):
        self.moves = player1Moves
    elif (self.player == 2):
        self.moves = player2Moves
    self.idleCount += 1
    margin = 5
    boarderLeft = ((0 + margin) + (self.width // 2))
    boarderRight = ((screenWidth - margin) - (self.width // 2))
    boarderBottom = ((screenHeight - margin) - (self.height // 2))
    if (self.moves['Left'] and (self.x > boarderLeft) and (not self.isJump) and (not self.isBlock) and (not self.isDamage)):
        self.x -= Character.runVel
        self.baseImage = pygame.transform.flip(self.spriteDict['run'], True, False)
        self.isRunLeft = True
        self.isIdle = False
    if (self.isRunLeft and (not self.isJump) and (not self.moves['Left'])):
        self.isRunLeft = False
        self.isIdle = True
        self.baseImage = self.spriteDict['idle']
    if (self.moves['Right'] and (self.x < boarderRight) and (not self.isJump) and (not self.isBlock) and (not self.isDamage)):
        self.x += Character.runVel
        self.baseImage = self.spriteDict['run']
        self.isRunRight = True
        self.isIdle = False
    if (self.isRunRight and (not self.isJump) and (not self.moves['Right'])):
        self.isRunRight = False
        self.isIdle = True
        self.baseImage = self.spriteDict['idle']
    if (self.moves['Down'] and (not self.isJump) and (not self.isDamage)):
        self.baseImage = self.spriteDict['block']
        self.isBlock = True
        self.isIdle = False
    if (self.isBlock and (not self.moves['Down'])):
        self.isBlock = False
        self.isIdle = True
        self.baseImage = self.spriteDict['idle']
    if (self.moves['Up'] and (self.y >= boarderBottom) and (not self.isJump) and (not self.isBlock) and (not self.isDamage)):
        self.sounds['jump'].play()
        self.baseImage = self.spriteDict['jump']
        self.isJump = True
        self.isIdle = False
    elif self.isJump:
        if (self.jumpVel >= 0):
            self.y -= ((self.jumpVel ** 2) // 2)
            if (self.isRunLeft and ((self.x - Character.runVel) >= boarderLeft)):
                self.x -= Character.runVel
            elif (self.isRunRight and ((self.x + Character.runVel) <= boarderRight)):
                self.x += Character.runVel
            self.jumpVel -= Character.gravity
        else:
            self.y += ((self.jumpVel ** 2) // 2)
            if (self.isRunLeft and ((self.x - Character.runVel) >= boarderLeft)):
                self.x -= Character.runVel
            elif (self.isRunRight and ((self.x + Character.runVel) <= boarderRight)):
                self.x += Character.runVel
            self.jumpVel -= Character.gravity
        if (self.y > self.idleY):
            self.baseImage = self.spriteDict['idle']
            self.y = self.idleY
            self.isJump = False
            self.isRunLeft = False
            self.isRunRight = False
            self.isIdle = True
            self.jumpVel = 10
    if (self.moves['Punch'] and self.isIdle and (self.idleCount >= 20) and (not self.isPunch) and (not self.isDamage)):
        self.sounds['punch'].play()
        self.baseImage = self.spriteDict['punch']
        self.isPunch = True
        self.isIdle = False
    elif self.isPunch:
        if (self.punchCount >= 0):
            self.punchCount -= 1
        else:
            self.isPunch = False
            self.isIdle = True
            self.idleCount = 0
            self.punchCount = 20
            self.baseImage = self.spriteDict['idle']
    if (self.moves['Kick'] and self.isIdle and (self.idleCount >= 20) and (not self.isDamage)):
        self.sounds['kick'].play()
        self.baseImage = self.spriteDict['kick']
        self.isKick = True
        self.isIdle = False
    elif self.isKick:
        if (self.kickCount >= 0):
            self.kickCount -= 1
        else:
            self.isKick = False
            self.isIdle = True
            self.idleCount = 0
            self.kickCount = 20
            self.baseImage = self.spriteDict['idle']
    if (self.moves['Special1'] and self.isIdle and (self.idleCount >= 20) and (self.energy >= self.specialDamage) and (not self.isJump) and (not self.isBlock) and (not self.isDamage)):
        self.sounds['special1'].play()
        self.baseImage = self.spriteDict['special1']
        self.isSpecial = True
        self.isIdle = False
        self.energy -= self.specialDamage
    elif self.isSpecial:
        if (self.specialCount >= 0):
            self.specialCount -= 1
        else:
            self.isSpecial = False
            self.isIdle = True
            self.idleCount = 0
            self.specialCount = 30
            self.baseImage = self.spriteDict['idle']
    super(Character, self).update(screenWidth, screenHeight)
def update(self, dt, keysDown, screenWidth, screenHeight):
    if self.isRight:
        self.spriteDict = self.spriteRightDict
    elif (not self.isRight):
        self.spriteDict = self.spriteLeftDict
    player1Moves = {'Left': keysDown(pygame.K_a), 'Right': keysDown(pygame.K_d), 'Down': keysDown(pygame.K_s), 'Up': keysDown(pygame.K_w), 'Punch': keysDown(pygame.K_v), 'Kick': keysDown(pygame.K_c), 'Special1': keysDown(pygame.K_SPACE)}
    player2Moves = {'Left': keysDown(pygame.K_LEFT), 'Right': keysDown(pygame.K_RIGHT), 'Down': keysDown(pygame.K_DOWN), 'Up': keysDown(pygame.K_UP), 'Punch': keysDown(pygame.K_l), 'Kick': keysDown(pygame.K_k), 'Special1': keysDown(pygame.K_j)}
    if (self.player == 1):
        self.moves = player1Moves
    elif (self.player == 2):
        self.moves = player2Moves
    self.idleCount += 1
    margin = 5
    boarderLeft = ((0 + margin) + (self.width // 2))
    boarderRight = ((screenWidth - margin) - (self.width // 2))
    boarderBottom = ((screenHeight - margin) - (self.height // 2))
    if (self.moves['Left'] and (self.x > boarderLeft) and (not self.isJump) and (not self.isBlock) and (not self.isDamage)):
        self.x -= Character.runVel
        self.baseImage = pygame.transform.flip(self.spriteDict['run'], True, False)
        self.isRunLeft = True
        self.isIdle = False
    if (self.isRunLeft and (not self.isJump) and (not self.moves['Left'])):
        self.isRunLeft = False
        self.isIdle = True
        self.baseImage = self.spriteDict['idle']
    if (self.moves['Right'] and (self.x < boarderRight) and (not self.isJump) and (not self.isBlock) and (not self.isDamage)):
        self.x += Character.runVel
        self.baseImage = self.spriteDict['run']
        self.isRunRight = True
        self.isIdle = False
    if (self.isRunRight and (not self.isJump) and (not self.moves['Right'])):
        self.isRunRight = False
        self.isIdle = True
        self.baseImage = self.spriteDict['idle']
    if (self.moves['Down'] and (not self.isJump) and (not self.isDamage)):
        self.baseImage = self.spriteDict['block']
        self.isBlock = True
        self.isIdle = False
    if (self.isBlock and (not self.moves['Down'])):
        self.isBlock = False
        self.isIdle = True
        self.baseImage = self.spriteDict['idle']
    if (self.moves['Up'] and (self.y >= boarderBottom) and (not self.isJump) and (not self.isBlock) and (not self.isDamage)):
        self.sounds['jump'].play()
        self.baseImage = self.spriteDict['jump']
        self.isJump = True
        self.isIdle = False
    elif self.isJump:
        if (self.jumpVel >= 0):
            self.y -= ((self.jumpVel ** 2) // 2)
            if (self.isRunLeft and ((self.x - Character.runVel) >= boarderLeft)):
                self.x -= Character.runVel
            elif (self.isRunRight and ((self.x + Character.runVel) <= boarderRight)):
                self.x += Character.runVel
            self.jumpVel -= Character.gravity
        else:
            self.y += ((self.jumpVel ** 2) // 2)
            if (self.isRunLeft and ((self.x - Character.runVel) >= boarderLeft)):
                self.x -= Character.runVel
            elif (self.isRunRight and ((self.x + Character.runVel) <= boarderRight)):
                self.x += Character.runVel
            self.jumpVel -= Character.gravity
        if (self.y > self.idleY):
            self.baseImage = self.spriteDict['idle']
            self.y = self.idleY
            self.isJump = False
            self.isRunLeft = False
            self.isRunRight = False
            self.isIdle = True
            self.jumpVel = 10
    if (self.moves['Punch'] and self.isIdle and (self.idleCount >= 20) and (not self.isPunch) and (not self.isDamage)):
        self.sounds['punch'].play()
        self.baseImage = self.spriteDict['punch']
        self.isPunch = True
        self.isIdle = False
    elif self.isPunch:
        if (self.punchCount >= 0):
            self.punchCount -= 1
        else:
            self.isPunch = False
            self.isIdle = True
            self.idleCount = 0
            self.punchCount = 20
            self.baseImage = self.spriteDict['idle']
    if (self.moves['Kick'] and self.isIdle and (self.idleCount >= 20) and (not self.isDamage)):
        self.sounds['kick'].play()
        self.baseImage = self.spriteDict['kick']
        self.isKick = True
        self.isIdle = False
    elif self.isKick:
        if (self.kickCount >= 0):
            self.kickCount -= 1
        else:
            self.isKick = False
            self.isIdle = True
            self.idleCount = 0
            self.kickCount = 20
            self.baseImage = self.spriteDict['idle']
    if (self.moves['Special1'] and self.isIdle and (self.idleCount >= 20) and (self.energy >= self.specialDamage) and (not self.isJump) and (not self.isBlock) and (not self.isDamage)):
        self.sounds['special1'].play()
        self.baseImage = self.spriteDict['special1']
        self.isSpecial = True
        self.isIdle = False
        self.energy -= self.specialDamage
    elif self.isSpecial:
        if (self.specialCount >= 0):
            self.specialCount -= 1
        else:
            self.isSpecial = False
            self.isIdle = True
            self.idleCount = 0
            self.specialCount = 30
            self.baseImage = self.spriteDict['idle']
    super(Character, self).update(screenWidth, screenHeight)