|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 cats_miao 于 2018-3-24 09:04 编辑
还有一个调用的py文件
在这里 http://bbs.fishc.com/thread-107447-1-1.html
可以复制这2个文件代码,运行试.
我的不行...希望大神们能解决一下,谢谢
import time
import pygame
from plane_sprites import *
class PlaneGame(object):
"""飞机大战主游戏"""
def __init__(self):
print("游戏初始化")
# 1.创建游戏的窗口
self.screen = pygame.display.set_mode(SCREEN_RECT.size)
# 2.创建游戏的时钟
self.clock = pygame.time.Clock()
# 3.调用私有方法,精灵和精灵组的创建
self.__create_sprites()
def __create_sprites(self):
pass
def start_game(self):
pygame.init()
print("游戏开始....")
while True:
# 1.设置刷新帧率
self.clock.tick(60)
# 2.事件监听
self.__event_handler()
# 3.碰撞检测
self.__check_collide()
# 4.更新/绘制精灵组
self.__update_sprites()
# 5.更新显示
pygame.display.update()
def __event_handler(self):
for event in pygame.event.get():
if event.type == pygame.quit():
PlaneGame.__game_over()
def __check_collide(self):
pass
def __update_sprites(self):
pass
@staticmethod
def __game_over():
print("游戏结束")
pygame.quit()
exit()
if __name__ == '__main__':
# 创建游戏对象
game = PlaneGame()
# 启动游戏
game.start_game()
运行主文件 plane_main.py 后
出现如下问题:
游戏初始化
游戏开始....
Traceback (most recent call last):
File "/home/miao/planeGame/p_game_1/plane_main.py", line 65, in <module>
game.start_game()
File "/home/miao/planeGame/p_game_1/plane_main.py", line 37, in start_game
pygame.display.update()
pygame.error: video system not initialized
Process finished with exit code 1
请各位大神帮忙解决一下,万分感谢!!! |
|