title: PyGame Collisions does only work on one side of the rectangle
body: <p>I'm just trying something with collisions and found the way to check one side of the rectangle with the other side.</p>
  <p><strong>I have the following problem:</strong></p>
  <p>If I move my game character (pink box) from the left against the object, my game character just moves through it:</p>
  <p><a href="https://i.stack.imgur.com/dc4Dr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dc4Dr.png" alt="Picture where it moves through it" /></a></p>
  <p>If I come from the other side, everything works and my game character stops.</p>
  <p><a href="https://i.stack.imgur.com/5EJTC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5EJTC.png" alt="Picture where it stops" /></a></p>
  <p>I mean to say that I need the same code for both sides but have to change the sides from <code>if not player_rect.left == other_rect.right:</code> <em>to</em> <code>if not player_rect.right == other_rect.left:</code>. But this does not work for one side.</p>
  <pre><code>import pygame
  import sys
  
  pygame.init()
  
  clock = pygame.time.Clock()
  window = pygame.display.set_mode([1200, 800])
  pygame.display.set_caption(&quot;Collision Test&quot;)
  
  x = 300
  y = 300
  width = 48
  height = 96
  velocity = 5
  
  running = True
  while running:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              sys.exit()
  
          is_pressed = pygame.key.get_pressed()
          player_rect = pygame.Rect(x, y, width, height)
          other_rect = pygame.Rect(400, 300, 50, 50)
  
          if is_pressed[pygame.K_d]:
              if not player_rect.right == other_rect.left:
                  x += velocity
          if is_pressed[pygame.K_a]:
              if not player_rect.left == other_rect.right:
                  x -= velocity
  
      window.fill((100, 150, 50))
      pygame.draw.rect(window, (255, 50, 100), player_rect)
      pygame.draw.rect(window, (255, 100, 50), other_rect)
      pygame.display.update()
      clock.tick(60)
  
  </code></pre>