python外星人入侵游戏run_game报错_《python编程从入门到实践》书中的外星人入侵小游戏报错...

在PyCharm环境下运行《Python编程从入门到实践》中的外星人入侵游戏代码时,遇到AttributeError:module 'game_functions' has no attribute 'check_evnets'。错误源于game_functions模块中函数名拼写错误,应为'check_events'。修正此拼写错误即可解决报错。
摘要由CSDN通过智能技术生成

使用该书发布的附件中的参考代码在Pyhton3.7 Pycharm2019.2.4(最新版本)的环境下运行,出现报错如下:

Traceback (most recent call last):

File "F:/python_work/AI/Alien_Invasion.py", line 25, in

run_game()

File "F:/python_work/AI/Alien_Invasion.py", line 21, in run_game

gf.check_evnets(ship)

AttributeError: module 'game_functions' has no attribute 'check_evnets'

使用的相关具体代码如下:(并没有贴settings.py和bullet.py)

alien_invasion.py

import pygame

from pygame.sprite import Group

from settings import Settings

from ship import Ship

import game_functions as gf

def run_game():

# Initialize pygame, settings, and screen object.

pygame.init()

ai_settings = Settings()

screen = pygame.display.set_mode(

(ai_settings.screen_width, ai_settings.screen_height))

pygame.display.set_cap

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值