title: My Pygame surface is not getting pushed back down by gravity
body: <p>I would really like the purple_idle_rect to be able to jump in the air, then get pulled down by gravity. What really happens here is that once I jump, I am stuck in the air then once I press the jump button again I fall. Basically, I need to press the up arrow key twice to fully jump and land on the ground.</p>
  <pre><code>import pygame
  
  # import n stuff
  import pygame
  pygame.init()
  
  # Screen and setup
  Screen = pygame.display.set_mode((900, 500))
  
  # Velocity
  Velocity = 8
  
  # Purple who sleep
  purple_sleeping = pygame.transform.scale(pygame.image.load(&quot;purple_guy_sleeping.png&quot;), (100, 100))
  purple_sleeping_rect = purple_sleeping.get_rect(center=(450, 302))
  
  # Purple who stand
  purple_idle = pygame.transform.scale(pygame.image.load(&quot;purple_man_idle.png&quot;), (100, 100))
  purple_idle_rect = purple_idle.get_rect(midbottom = (100,360))
  
  # The ground
  ground = pygame.transform.scale(pygame.image.load(&quot;a2889b85d5c7122.png&quot;), (800, 100))
  # Main loop
  Run = True
  FPS = 60
  Clock = pygame.time.Clock()
  #  All of our keys
  pressed_keys = {&quot;left&quot;: False, &quot;right&quot;: False}
  
  #  Gravity
  player_gravity = 0
  isJump = False
  while Run:
      pygame.display.update()
      Screen.fill(&quot;black&quot;)
      Screen.blit(ground, (45, 350))
      Screen.blit(purple_sleeping, purple_sleeping_rect)
      Screen.blit(purple_idle, purple_idle_rect)
      Clock.tick(FPS)
      keys = pygame.key.get_pressed()
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              pygame.quit()
              exit()
          if event.type == pygame.KEYDOWN:
              if event.key == pygame.K_LEFT:
                  pressed_keys[&quot;left&quot;] = True
              if event.key == pygame.K_RIGHT:
                  pressed_keys[&quot;right&quot;] = True
              if event.key == pygame.K_UP and purple_idle_rect.bottom == 360:
                  player_gravity -=20
          elif event.type == pygame.KEYUP:
              if event.key == pygame.K_LEFT:
                  pressed_keys[&quot;left&quot;] = False
              if event.key == pygame.K_RIGHT:
                  pressed_keys[&quot;right&quot;] = False
              if purple_idle_rect.bottom == 360:
                  isJump = False
                  if not isJump:
                      purple_idle_rect.bottom = 360
              if purple_idle_rect.bottom &lt; 360:
                  isJump = True
                  if isJump:
                      player_gravity += 20
  
      if pressed_keys[&quot;left&quot;]:  # == True is implied here
          purple_idle_rect.x -= 10
      if pressed_keys[&quot;right&quot;]:
          purple_idle_rect.x += 10
      purple_idle_rect.bottom += player_gravity
      if purple_idle_rect.bottom &gt; 360:
          purple_idle_rect.bottom = 360
      pygame.display.update()
  
  </code></pre>