在pygame写游戏出现pygame.error: video system not initialized

源代码

import sys
import pygame
def run_game():
pygame.init()
screen = pygame.display.set_mode((1200,800))
pygame.display.set_caption("Alien Invasion")

#主循环
while True:
#监视键盘和鼠标事件
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()

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

run_game()
报错

Traceback (most recent call last):
File "D:/project/python/FirstGame/alien_invasion.py", line 11, in <module>
for event in pygame.event.get():
pygame.error: video system not initialized


原因在于while true没有放进主循环,没有缩进

pygame.error: video system not initialized的更多相关文章

  1. python中video system not initialized怎么解决

    今天在github上找到一个用pygame做的Python游戏,但是clone到本地运行的时候却冒出了“mixer system not initialized”这样的问题.其实这句话说的就是音频混音 ...

  2. CodeForces 527B Error Correct System

    Error Correct System Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I6 ...

  3. CF Error Correct System

    Error Correct System time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  4. E514:write error(file system full?)

    vi编辑某文件,保存时报错,提示:E514: write error (file system full?)---写入错误,磁盘满了? 查看磁盘空间:df -h根目录磁盘空间已满,used%100. ...

  5. Error Correct System(模拟)

     Error Correct System Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I ...

  6. 解决编译时出错提示: 'error: array must be initialized with a brace-enclosed initializer' 的错误

    编译出现这个错误的原因非常简单编译的标准不相同.如果用stdc90,这个就可以直接编译通过了. 下面是代码例子: ...... ] = NULL;或者 :char cmd[256] = '\0'; . ...

  7. Bus Video System CodeForces - 978E (思维)

    The busses in Berland are equipped with a video surveillance system. The system records information ...

  8. 解决 Error: ENOSPC: System limit for number of file watchers reached

    manjaro 18.0 kde版本 运行 yarn test报错 Error: ENOSPC: System limit for number of file watchers reached 解决 ...

  9. pygame.error: Couldn't open images/ship.bmp

    在<python编程:从入门到实践>这本书中的<外星人入侵>的项目里有如下代码:  Python Code  123456789101112131415   import py ...

随机推荐

  1. js根据ClassName来删除元素(有坑误入)

    今天,被一个很简单的问题坑了一下午,基础不扎实.(js根据class名称来删除Dom元素) 但是结果却不是这样的.弄了好久还不知道怎么回事.最后找到了答案. 结果如下:为啥还有test2,4,6呢. ...

  2. Java基础--集合解析-ArrayList

    1.ArrayList中添加,获取,删除元素: 2.ArrayList中是否包含某个元素: 3.ArrayList中根据索引将元素数值改变(替换): 4.ArrayList中查看(判断)元素的索引: ...

  3. POJ1990 题解

    题目大意:有若干头牛,每个牛有一个音量值,两头牛能互相听见对方说话需要发出两头牛中音量值较大者的音量*两头牛的距离的音量,求使任意两头牛都互相听见对方需要发出的音量总和.每头牛的音量值可以相同,但坐标 ...

  4. MySQL之InnoDB存储引擎 - 读书笔记

    1. MySQL 的存储引擎 MySQL 数据库的一大特色是有插件式存储引擎概念.日常使用频率最高的两种存储引擎: InnoDB 存储引擎支持事务,其特点是行锁设计.支持外键.非锁定读(默认读取操作不 ...

  5. tar包压缩时相对路径问题

    一.问题描述 现在有一个需求,不知道该如何才能实现压缩: tar -czvf /home/futong/test/logs.tar.gz /home/futong/test/logs 打开压缩包发现 ...

  6. 根据文件url,下载文件到本地

    /// <summary> /// 根据文件url,下载文件到本地 /// </summary> /// <param name="fileUrl"& ...

  7. redis缓存雪崩和缓存穿透

    缓存雪崩:由于原有的缓存过期失效,新的缓存还没有缓存进来,有一只请求缓存请求不到,导致所有请求都跑去了数据库,导致数据库IO.内存和CPU眼里过大,甚至导致宕机,使得整个系统崩溃. 解决思路:1,采用 ...

  8. Anaconda 下 Jupyter 更改默认启动路径方法(转)

    https://www.cnblogs.com/awakenedy/p/9075712.html

  9. Actor model 的理解与 protoactor-go 的分析

    Overview Definition From wikipedia The actor model in computer science is a mathematical model of co ...

  10. tp5 Redis缓冲的设置与清除

    控制器代码: //设置缓冲的方法 public function order() { $word = input('word');//接受搜索值 //题意:将订单数据使用redis进行缓存中,第二次读 ...