title: AttributeError: 'pygame.Surface' object has no attribute 'ship_img'
body: <p>So, I was doing a project by the help of a YouTube tutorial and suddenly I got this error. I searched the entire internet reviewed it again and again, but nothing worked.I don't understand what is happening, Can you please help me? This is the error:
  AttributeError: 'pygame.Surface' object has no attribute 'ship_img'</p>
  <pre><code>import pygame
  import os
  pygame.font.init()
  
  # screen
  wth, hht = 800, 600
  window = pygame.display.set_mode((wth, hht))
  pygame.display.set_caption(&quot;Space Invaders&quot;)
  
  # load images
  red_space_ship = pygame.image.load(os.path.join(&quot;F:/shaan/python/pixel_ship_red_small.png&quot;))
  green_space_ship = pygame.image.load(os.path.join(&quot;F:/shaan/python/pixel_ship_green_small.png&quot;))
  blue_space_ship = pygame.image.load(os.path.join(&quot;F:/shaan/python/pixel_ship_blue_small.png&quot;))
  
  # player ship
  yellow_space_ship = pygame.image.load(os.path.join(&quot;F:/shaan/python/pixel_ship_yellow.png&quot;))
  
  # lasers
  red_laser = pygame.image.load(os.path.join(&quot;F:/shaan/python/pixel_laser_red.png&quot;))
  green_laser = pygame.image.load(os.path.join(&quot;F:/shaan/python/pixel_laser_green.png&quot;))
  blue_laser = pygame.image.load(os.path.join(&quot;F:/shaan/python/pixel_laser_blue.png&quot;))
  yellow_laser = pygame.image.load(os.path.join(&quot;F:/shaan/python/pixel_laser_yellow.png&quot;))
  
  # Background
  BG = pygame.transform.scale(pygame.image.load(os.path.join(&quot;F:/shaan/python/oackground-black.png&quot;)), (wth, hht))
  
  
  class Ship:
      def __init__(self, x, y, health=100):
          self.x = x
          self.y = y
          self.health = health
          self.ship_img = None
          self.laser_img = None
          self.lasers = []
          self.cool_down_counter = 0
  
      def get_width(self):
          return self.ship_img.get_width()
  
      def get_height(self):
          return self.ship_img.get_height()
  
      def draw(self, windows):
          windows.blit(self.ship_img, (self.x, self.y))
  
  
  class Player(Ship):
      def __init__(self, x, y, health=100):
          super().__init__(x, y, health)
          self.ship_img = yellow_space_ship
          self.laser_img = yellow_laser
          self.mask = pygame.mask.from_surface(self.ship_img)
          self.max_health = health
  
  
  def main():
      run = True
      fps = 60
      level = 1
      lives = 5
      main_font = pygame.font.SysFont(&quot;comicsans&quot;, 20)
  
      player_vel = 5
  
      clock = pygame.time.Clock()
  
      def redraw_window(windows):
          window.blit(BG, (0, 0))
          # text
          lives_label = main_font.render(f&quot;Lives: {lives}&quot;, True, (255, 255, 255))
          level_label = main_font.render(f&quot;Level: {level}&quot;, True, (255, 255, 255))
  
          window.blit(lives_label, (10, 10))
          window.blit(lives_label, (wth - level_label.get_width() - 10, 10))
  
          Ship.draw(window, windows)
  
          pygame.display.update()
  
      while run:
          clock.tick(fps)
          redraw_window(window)
          for event in pygame.event.get():
              if event.type == pygame.QUIT:
                  run = False
  
          keys = pygame.key.get_pressed()
          if keys[pygame.K_a] and Player.x - player_vel &gt; 0:
              Player.x -= player_vel
          if keys[pygame.K_d] and Player.x + player_vel + Player.get_width() &lt; wth:
              Player.x += player_vel
          if keys[pygame.K_w] and Player.y - player_vel &gt; 0:
              Player.y -= player_vel
          if keys[pygame.K_s] and Player.y + player_vel + Player.get_height() &lt; hht:
              Player.y += player_vel
  
  
  main()
  
  </code></pre>
  <p>The whole error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;F:\shaan\python\Main.py&quot;, line 99, in &lt;module&gt;
      main()
    File &quot;F:\shaan\python\Main.py&quot;, line 83, in main
      redraw_window(window)
    File &quot;F:\shaan\python\Main.py&quot;, line 77, in redraw_window
      Ship.draw(window, windows)
    File &quot;F:\shaan\python\Main.py&quot;, line 45, in draw
      windows.blit(self.ship_img, (self.x, self.y))
  AttributeError: 'pygame.Surface' object has no attribute 'ship_img'
  </code></pre>