[Python] How can I make a jump function, that won't cause errors? [duplicate]

Discussão em 'Python' iniciado por Stack, Janeiro 31, 2025.

  1. Stack

    Stack Membro Participativo

    Making a game on pygame and I have a jump function that won't work about 1/4 of the time

    def jump(self):
    self.vel_y -= 7
    if self.extraJump == True:
    self.jumps += 1
    self.extraJump = False
    self.jumps -=1

    def dJump(self):
    if king.rect.bottom >= height - 5 and king.rect.bottom <= height +5:
    isOnGround = True
    else: isOnGround = False
    if king.jumps <= 2 and isOnGround:
    king.jumps = 2
    if pygame.key.get_pressed()[pygame.K_UP] and king.jumps > 0:
    now = pygame.time.get_ticks()
    if now - self.last >= self.cooldown:
    self.last = now
    self.jump()

    Continue reading...

Compartilhe esta Página