title: How can I make Pygame check if two images are colliding?
body: <p>I've tried everything and cannot get how I check if my two blocks have collided.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>import pygame
  import random
  pygame.init()
  
  display_width = 600
  display_height = 300
  
  class player:#Just info for player
      width = 30
      height = 30
      x = display_width // 2
      y = display_height - height - 5
      a = x + 30
      pic = 'SnakePart.png'
      thing = pygame.image.load(pic)
      def place(x,y):#function for placing player object
          gameDisplay.blit(player.thing, (player.x,player.y))
  class enemy:#enemy info class
      width = 30
      height = 30
      x = random.randint(0,display_width - width)
      y = 1
      a = x + 30
      pic = 'Apple.png'
      thing = pygame.image.load(pic)
      speed = 10#sets speed
      def change_x():
          enemy.x = random.randint(0,display_width - enemy.width)
      def change_y():
          enemy.y += enemy.speed
      def make(x,y):#set up funtion
          gameDisplay.blit(enemy.thing, (x,y))
      def respawn():#reseting enemy entity
          enemy.y = 1
          gameDisplay.blit(enemy.thing, (enemy.x,enemy.y))
  player.thing#uses the variables in the classes to set up the images for use
  enemy.thing
  
  black = (0,0,0)
  white = (255,255,255)
  
  
  player_height = 30
  player_width = 30
  
  clock = pygame.time.Clock()
  
  x_change = 0#This is to make movment
  
  gameDisplay = pygame.display.set_mode((display_width,display_height))
  pygame.display.set_caption('Bullet Hell.')
  
  dodged = 0#counter will be used in the more polished vesion.
  
  while True:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              pygame.quit()
              quit()
          if event.type == pygame.KEYDOWN:#Checks for keypress, to make player entity move
              if event.key == pygame.K_RIGHT:
                  x_change = 5
              if event.key == pygame.K_LEFT:
                  x_change = -5
          if event.type == pygame.KEYUP:
              if event.key == pygame.K_RIGHT or pygame.K_LEFT:
                  x_change = 0
  
      player.x += x_change
      gameDisplay.fill(black)
      enemy.make(enemy.x,enemy.y)
      player.place(player.x,player.y)
      enemy.change_y()
      if enemy.y &gt; display_height:#Brings enemy back to top once it has gotten to th bottom
          enemy.change_x()
          dodged += 1
          enemy.respawn()
      pygame.display.update()
      clock.tick(60)
  </code></pre>
  
  <p>It's all really the collision and I think I'll be good. Oh yeah, if you guys could also tell me how to display text that would be great!</p>