title: pygame: I can't make one rectangle notice when the other comes in contact
body: <pre><code>import pygame
  import time
  import random
  
  pygame.init()
  
  white = (255,255,255)
  black = (0,0,0)
  red = (255,0,0)
  green = (0,155,0)
  blue = (0, 0, 200)
  
  #img = pygame.image.load("rectangle.png")
  
  displayW = 500
  displayH = 500
  
  display = pygame.display.set_mode((displayW, displayH))
  pygame.display.update()
  
  clock = pygame.time.Clock()
  
  rectSize = 40
  obstacleSize = 30
  
  FPS = 30
  
  def left(obstaclex,obstacley):
      pygame.draw.rect(display, blue, [0, obstacley, rectSize, rectSize])
  
  def right(rectx,recty):
      pygame.draw.rect(display, blue, [rectx, recty, rectSize, rectSize])
  
  def middleL(obstaclex, obstacley):
      obstacleSize = -230
      obstaclex = 500
      pygame.draw.rect(display, red, [obstaclex,obstacley, obstacleSize, rectSize])
  
  def middleR(obstaclex, obstacley):
      obstacleSize = 210
      obstaclex = 0
      #display.blit(img, (obstaclex, obstacley))
      pygame.draw.rect(display, red, [obstaclex, obstacley, obstacleSize, 40])
  def middle(obstaclex, obstacley):
  
      middleL(obstaclex, obstacley)
      middleR(obstaclex, obstacley)
  
  
  
  def gameLoop():
      gameExit = False
      gameOver = False
  
      obstacley = 10
      obstaclex = 1
  
      rectx = 220
      recty = 400
  
      rect1 = (rectx, recty, rectSize, rectSize)
  
  
      obstacleRectX = 0
      obstacleRectY = 20
  
      obstacleChangeX = 0
      obstaleChageY = 0
      randrect = random.randrange(0,4)
  
      myRight = rectx + rectSize
      myLeft = rectx
      myTop = recty
      myBottom = recty + rectSize
  
      otherRight = obstaclex + obstacleSize
      otherLeft = obstaclex
      otherTop = obstacley
      otherBottom = obstacley + rectSize
  
      randObstacle = random.randrange(0,2)
  
      while not gameExit:
  
          pressed = pygame.key.get_pressed()
  
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  gameExit = True
  
          display.fill(black)
          pygame.draw.rect(display, blue, [rectx, recty, rectSize, rectSize])
  
          if pressed[pygame.K_RIGHT]:
              display.fill(black)
              rectx = displayW/2 + 70 + rectSize
              right(rectx,recty)
  
          if pressed[pygame.K_LEFT]:
              display.fill(black)
              rectx = displayW/2 - 170
              left(rectx,recty)
  
          if pressed[pygame.K_LEFT] and pressed[pygame.K_RIGHT]:
              display.fill(black)
              rectx = displayW/2 + 100
              right(rectx,recty)
              rectx = displayW/2 - 170
              left(rectx,recty)
  
          else:
              display.fill(black)
              pygame.draw.rect(display, blue, [rectx, recty, rectSize, rectSize])
              rectx = displayW/2 - 30
  
  ##        if randObstacle == 0:
  ##            
  ##            middleL(obstaclex, obstacley)
  ##            obstacley += 5
  ##            randObstacle = random.randrange(0,2)
  ##        elif randObstacle == 1:
  ##            
  ##            middleR(obstaclex, obstacley)
  ##            obstacley += 5
  ##            randObstacle = random.randrange(0,2)
  ##        elif randObstacle == 2:
  ##            
  ##            middle(obstaclex, obstacley)
  ##            obstacley += 5
  ##            randObstacle = random.randrange(0,2)
  
  
          middleR(obstaclex, obstacley)
          obstacley += 5
          collision = True
          if ((myRight &lt; otherLeft) and (myLeft &gt; otherRight) and (myBottom &lt; otherTop) and (myTop &gt; otherBottom)):
              # i replaced the OR's with AND's
              collision = False
              print collision
  
  
          pygame.display.update()
  
          clock.tick(FPS)
      pygame.quit()
      quit()
  gameLoop()
  </code></pre>
  
  <p>I am trying to make one rectangle collide with a rectangle falling down towards it, however I cannot seem to make them collide correctly. I would like to do this with an if statement and not something such as <code>sprite.collide()</code>.</p>
  
  <p>This code is not very refined, I will fix it up but for the time being to help me understand the code a little more.</p>
  
  <p>**This is the edited code **</p>