Endured_Programmer
Endured_Programmer

Reputation: 45

IndentationError but it's not mixing up tabs and spaces

When I try and run my script it insists that there's an IndentationError on line 10, the def init(self): line. Looking it up I tried some of the common fixes I've seen, checking to make sure tabs and spaces aren't mixed up, making sure loops are properly structured, but nothing's working!

import sys
import pygame

from settings import Settings
from ship import Ship

class AlienInvasion:
  """Overall game assets and behavior"""
    
    def __init__(self):
        """Initialize the game, and create game resources"""
        pygame.init()
        
        self.settings = Settings()pi
        self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height))

        pygame.display.set_caption("Alien Invasion")

        self.ship = Ship(self)

        # Set the background
        self.bg_color = (230, 230, 230)

    def run_game(self):
        """Start the main loop for the game"""
        while True:
            # Watch for keyboard and mouse events.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()

                # Redraw the screen during each pass through the pass
                self.screen.fill(self.settings.bg_color)
                self.ship.blitme()

            # Make the most recently drawn screen visible
            pygame.display.flip()

if __name__ == '__main__':
    # Make a game instance, and run the game
    ai = AlienInvasion()
    ai.run_game()

If anyone can tell me what's happening that'd be appreciated. Trying out Python so late into my coding life is a doozy.

Upvotes: 1

Views: 49

Answers (1)

Acorn
Acorn

Reputation: 26194

This:

class AlienInvasion:
  """Overall game assets and behavior"""

Should be this:

class AlienInvasion:
    """Overall game assets and behavior"""

So that it matches the next definition:

    def __init__(self):

Upvotes: 2

Related Questions