找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 696|回复: 0

[求助] 外星人入侵 第一个模块就被难住了

1

主题

1

帖子

1

积分

贫民

积分
1
999 发表于 2022-8-4 11:37:05 | 显示全部楼层 |阅读模式
import sys
import pygame

class AlienInvasion:

    def __init__(self):
        """初始化并创建游戏资源"""
        pygame.init()

        self.cereen = pygame.display.set_mode((250, 600))
        pygame.display.set.caption("Alien   Invasion")

    def run_game(self):
        """开始游戏的主循环"""
        while True:
            #监视键盘和鼠标事件
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()

            #让最近绘制的屏幕可见
            pygame.display.flip()

if __name__ == "__main__":
    #创建游戏实例并运行
    ai = AlienInvasion
    ai.run_game()



D:\常试\Scripts\python.exe D:/pythonProject/常试/游戏代码/窗口.pyTraceback (most recent call last):  File "D:\pythonProject\常试\游戏代码\窗口.py", line 27, in <module>    ai.run_game()TypeError: run_game() missing 1 required positional argument: 'self'pygame 2.1.2 (SDL 2.0.18, Python 3.9.7)Hello from the pygame community. https://www.pygame.org/contribute.html进程已结束,退出代码为 1

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表