700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > python外星人入侵代码提示has no attri_Python中出现AttributeError: 'Ship' ob

python外星人入侵代码提示has no attri_Python中出现AttributeError: 'Ship' ob

时间:2023-11-29 00:16:53

相关推荐

python外星人入侵代码提示has no attri_Python中出现AttributeError: 'Ship' ob

当在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...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。