win7系统,照书上编写了一个python的飞船游戏,按照书上的编写的,但不知道问题出在哪里
AttributeError: 'str' object has no attribute 'get_rect'
完整代码
alien_invasion.py
import sys
import pygame
from settings import Settings
from ship import Ship
def run_game():
pygame.init()
ship = Ship('screen')
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width,ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
screen.fill(ai_settings.bg_color)
ship.blitme()
pygame.display.flip()
run_game()
settings.py
class Settings():
def __init__(self):
self.screen_width = 1200