当在alien_invasion.py中添加ship.update() Ship object has no attribute update,代码都是按照书上写得,求大佬解答一下出现错误题目描述
《Python编程从入门到实践》中外星人入侵的游戏编写题目来源及自己的思路
### alien_invasion.py
import pygame
import sys
from settings import Settings
from ship import Ship
import game_functions as gf
def run_game():
# 初始化游戏并创建一个屏幕对象
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode((ai_settings.screen_width,ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
# 创建飞船
ship = Ship(screen)
# 开始游戏的主循环
while True:
gf.check_events(ship)
ship.update()
gf.update_screen(ai_settings,screen,ship)
# 监视键盘和鼠标事件
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
python外星人入侵代码提示has no attri_Python中出现AttributeError: Ship object has no attribute update...