title: Python pygame how to shoot bullets from player
body: <p>I'm trying to get my code to shoot a pygame.rect across the screen from player location.
  Right now it shoots but when I let off the space button it doesn't reset the rect. I have it set to change the x coordinate but I want it to reset after I release the space button. </p>
  
  <p>if event.key == pygame.K_SPACE:
                          mx_change = -100</p>
  
  <p>can I use event.key == pygame.KEYUP: to reset it somehow?</p>
  
  <pre><code>    import pygame #####IMPORTING PYGAME MODULE###########################
  
      pygame.init() 
      #####INITIALIZINGPYGAME##################################
  
      gameWindow = pygame.display.set_mode((800,600)) ###Screen Width and 
      Height###
  
      clock = pygame.time.Clock() ## FRAMES PER SECOND ##
  
      white = (255,255,255)
      black = (0,0,0)
  
  
      def player(px,py):
      pygame.draw.rect(gameWindow,black,[px,py,30,30])
  
      def missile(mx,my):
      pygame.draw.rect(gameWindow,black,[mx,my,10,10])
  
  
      def gameloop():
  
          px = 700
          py = 300
  
          mx = 700
          my = 300
  
          px_change = 0
          py_change = 0
  
          mx_change = 0
          my_change = 0
  
          gameExit = False
  
          while not gameExit:
              for event in pygame.event.get():
                  if event.type == pygame.QUIT:
                      gameExit = True
                  if event.type == pygame.KEYDOWN:
                      if event.key == pygame.K_LEFT:
                          mx_change = -10
                      if event.key == pygame.K_RIGHT:
                          mx_change = 10
                      if event.key == pygame.K_UP:
                          my_change = -10
                      if event.key == pygame.K_DOWN:
                          my_change = 10
  
                      if event.key == pygame.K_SPACE:
                          mx_change = -100
  
  
                      if event.key == pygame.K_LEFT:
                          px_change = -10
                      if event.key == pygame.K_RIGHT:
                          px_change = 10
                      if event.key == pygame.K_UP:
                          py_change = -10
                      if event.key == pygame.K_DOWN:
                          py_change = 10
  
          if event.type == pygame.KEYUP:
              if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
                  px_change = 0
              if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
                  py_change = 0
  
          if event.type == pygame.KEYUP:
              if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
                  mx_change = 0
              if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
                  my_change = 0
              if event.key == pygame.K_SPACE:
                  mx_change = 0
                  my_change = 0
  
  
      px += px_change
      py += py_change
  
      mx += mx_change
      my += my_change
  
      gameWindow.fill(white)
  
      player(px,py)
      missile(mx,my)
      pygame.display.update()
  
      clock.tick(15)
  
  pygame.quit()
  quit()
  gameloop()
  </code></pre>