title: Pygame - shooting bullets
body: <p>I have problem with my code, I started to make 2D tank game, the problem is the shooting bullets from the tank position.. Here's my code, check it out, I'm trying to figure it out like 3-4 hours.. I hope someone knows how to do it, thanks!:)</p>
  
  <p>by the way, sorry for the creepy code, I'm new to Pygame :)</p>
  
  <pre><code>import pygame
  
  pygame.init()
  
  #---WINDOW----
  display_width = 1000
  display_height = 600
  
  gameDisplay = pygame.display.set_mode((display_width,display_height))
  pygame.display.set_caption('powpypow')
  
  black = (0,0,0)
  white = (255,255,255)
  red = (255,0,0)
  
  
  
  
  background = pygame.image.load('background.png')
  tank1 = pygame.image.load('tank1.png')
  tankfire = pygame.image.load('tankfire.png')
  shot = pygame.image.load('shot.png')
  
  clock = pygame.time.Clock()
  
  def tank(x,y):
      gameDisplay.blit(tank1, (x,y))
  
  x = (display_width * 0.10) 
  y = (display_height * 0.58)
  
  x_change = 0
  
  tank_width = 73 
  
  
  #---GAME LOOP----
  
  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_a:
                  x_change = -10
              elif event.key == pygame.K_d:
                  x_change = 10    
              elif event.key == pygame.K_SPACE:
                  tank1 = pygame.image.load('tankfire.png')
  
  
          if event.type == pygame.KEYUP:
              if event.key == pygame.K_a or event.key == pygame.K_d or event.key == pygame.K_SPACE:
                  tank1 = pygame.image.load('tank1.png')
                  x_change = 0 
  
      if x &gt;= display_width - tank_width or x &lt;= 0:
          x = 0
      if x &gt; display_width / 2:
          x = 0 
  
      x += x_change
      gameDisplay.blit(background, (0,0))
      tank(x,y)
  
      pygame.display.update()
      clock.tick(60)
  
  pygame.quit()
  quit()
  </code></pre>