-3
while run:
    clock.tick(FPS)
    if player.colliderect(ground):
       GRAVITY = 0
    else:
       GRAVITY = 10
       player.y - GRAVITY
      .....
 

    keys = pygame.key.get_pressed()
    if keys[pygame.K_d]:
     player.x += PLAYER_VEL 
    if keys[pygame.K_a] and player.x - PLAYER_VEL > 0:
     player.x -= PLAYER_VEL
    if keys[pygame.K_SPACE]:
     player.y -= PLAYER_VEL 
    else:
     player.y += GRAVITY
    `

jumping by pressing the spacebar instead of holding it when i press space my character flies instead of jumping and when i leave the space bar it goes down to the floor

Malek
  • 1

0 Answers0