AttributeError: 'AlienInvasion' object has no attribute 'settings'. Did you mean: 'settngs'?
麻烦指点下
import sys
import pygame
from settings import Settings
from ship import Ship
class AlienInvasion:
def __init__(self):
pygame.init()
self.settngs = Settings()
self.screen = pygame.display.set_mode(
(self.settngs.screen_width, self.settngs.screen_height))
pygame.display.set_caption("AlienInvasion")
self.ship = Ship(self)
def run_game(self):
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 loop.
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()