title: Python Pygame press two direction key and another key to shoot there's no bullet
body: <p>I am trying to make a ship shoot a bullet, and everything it works as expected except when I press both <kbd>UP</kbd>, <kbd>LEFT</kbd> and then <kbd>SPACE</kbd>. Then there's no bullet being fired. There's no bullet being fired for <kbd>RIGHT</kbd> + <kbd>DOWN</kbd> + <kbd>SPACE</kbd>, <kbd>UP</kbd> + <kbd>LEFT</kbd> + <kbd>SPACE</kbd> either.</p>
  <p>However, when I press both <kbd>UP</kbd>, <kbd>RIGHT</kbd> and then <kbd>SPACE</kbd>, it workes. In fact, every other direction key <kbd>LEFT</kbd> + <kbd>DOWN</kbd>, <kbd>UP</kbd> + <kbd>RIGHT</kbd>, <kbd>UP</kbd> + <kbd>DOWN</kbd> works with <kbd>SPACE</kbd> key.</p>
  <p>Here's the code:</p>
  <pre><code> #!/usr/bin/python
  import sys
  import pygame 
  
  class Setting:
      def __init__(self, width, height):
          self.w = width
          self.h = height
          self.flag = pygame.RESIZABLE
          self.color = (255, 255, 255)
          self.speed = 1.5
          self.screen = pygame.display.set_mode((self.w, self.h), self.flag)
          pygame.display.set_caption(&quot;Muhaha&quot;)
          self.bullet_s = 1.5
          self.bullet_w = 5
          self.bullet_h = 20
          self.bullet_c = (0, 0, 0)
  
  class Bullet(pygame.sprite.Sprite):
      def __init__(self, setting, char):
          super().__init__()
          self.rect = pygame.Rect(0, 0, setting.bullet_w, setting.bullet_h)
          self.rect.centerx = char.ship_rect.centerx
          self.rect.top = char.ship_rect.top
          self.color = setting.bullet_c
          self.speed = setting.bullet_s
          self.y = float(self.rect.centery)
      
      def move_bullet(self):
          self.y -= self.speed
          self.rect.y = self.y
      
      def draw_bullet(self, setting):
          pygame.draw.rect(setting.screen, self.color, self.rect)
  
      def blit_bullet(self, bullets, setting):
          for bullet in bullets.sprites():
               pygame.draw.rect(setting.screen, bullet.color, bullet.rect)
               bullet.y -= bullet.speed
               bullet.rect.y = bullet.y
         
  
  class Char:
      def __init__(self, screen, setting):
          bk = pygame.image.load(&quot;image/muha.png&quot;).convert()
          self.bkg = pygame.transform.smoothscale(bk, (setting.w, setting.h))
          temp = pygame.image.load(&quot;image/title.jpg&quot;).convert_alpha()
          self.ship = pygame.transform.smoothscale(temp, (200, 200))
          self.screen = screen
          self.screen_rect = screen.get_rect()
          self.ship_rect = self.ship.get_rect()
  
          self.ship_rect.center = self.screen_rect.center
          self.ship_rect.bottom = self.screen_rect.bottom
         
          self.x = float(self.ship_rect.centerx)
          self.y = float(self.ship_rect.centery)
  
      def blit_screen(self):
          self.screen.blit(self.bkg, (0, 0))
      
      def blit_ship(self):
          self.screen.blit(self.ship, self.ship_rect)
  
          
  class Check_event:
       def __init__(self):
          self.moving_up   = False
          self.moving_down = False
          self.moving_left = False
          self.moving_right = False
       
       def event(self, bullets, setting, char):      
           for event in pygame.event.get():
               if event.type == pygame.QUIT:
                   sys.exit()
               elif event.type == pygame.KEYDOWN:
                   if event.key == pygame.K_SPACE:
                      bullets.add(Bullet(setting, char))
                   elif event.key == pygame.K_UP:
                       self.moving_up = True
                   elif event.key == pygame.K_DOWN:
                       self.moving_down = True
                   elif event.key == pygame.K_LEFT:
                       self.moving_left = True
                   elif event.key == pygame.K_RIGHT:
                       self.moving_right = True
  
               elif event.type == pygame.KEYUP:
                   if event.key == pygame.K_UP:
                       self.moving_up = False
                   elif event.key == pygame.K_DOWN:
                       self.moving_down = False
                   elif event.key == pygame.K_LEFT:
                       self.moving_left = False
                   elif event.key == pygame.K_RIGHT:
                       self.moving_right = False
  
       def move(self, setting, char):
           if self.moving_up == True and char.ship_rect.top &gt;= 0:
              char.y -= setting.speed
           if self.moving_down == True and char.ship_rect.bottom &lt;= setting.h:
               char.y += setting.speed
           if self.moving_left == True and char.ship_rect.left &gt;= 0:
               char.x -= setting.speed
           if self.moving_right == True and char.ship_rect.right &lt;= setting.w:
               char.x += setting.speed
               # press both &quot;up&quot; &amp;&quot;left&quot; then press &quot;space&quot;
           char.ship_rect.centerx = char.x
           char.ship_rect.centery = char.y
  
  def game():
      pygame.init()
      setting = Setting(1200, 800)
      screen = setting.screen 
      char = Char(screen, setting)
      check_event = Check_event()
      bullet = Bullet(setting, char)
      bullets = pygame.sprite.Group()
                        
  
      while True:
          check_event.event(bullets, setting, char)
          
          char.blit_screen()
          check_event.event(bullets, setting, char)
          check_event.move(setting, char)
          bullet.blit_bullet(bullets, setting)
          
          char.blit_ship()
          pygame.display.flip()
  game()
  </code></pre>