在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. linux下确认裸盘是否使用-渐入佳境

    --作者:飞翔的小胖猪 --创建时间:2021年3月9日 6.1 概述 在私有云和虚拟化环境中业务方经常会根据自己的业务情况申请磁盘用作数据存储用.如果申请了磁盘但没有使用的情况,将极大的造成资源的浪 ...

  2. UnboundLocalError: local variable ‘xxx‘ referenced before assignment

    原因 在Python函数中调用了某个和全局变量同名的局部变量,导致编译器不知道此时使用的是全局变量还是局部变量 a = 3 def func(): a+=3 func() UnboundLocalEr ...

  3. Qt:QWebChannel

    0.说明 QWebChannel的作用是将QObject展示给的HTML客户. QWebChannel是连接C++应用和HTML/JS应用的桥梁.通过把一个QObject传入QWebChannel并在 ...

  4. springboot----四、yaml配置注入

    四.yaml配置注入 4.1.配置文件 SpringBoot使用一个全局的配置文件 , 配置文件名称是固定的 application.properties 语法结构 :key=value applic ...

  5. 前端工程化:使用 shelljs 生成 yapi 接口文件

    之前的文章介绍了使用 yapi-to-typescript (下文简称 ytt)生成接口类型定义文件,方便我们直接使用接口的请求和响应类型,能减少很多写接口类型的时间. 使用 yapi-to-type ...

  6. C++雾中风景18:C++20, 从concept开始

    转眼间,C++20的标准已经发布快两年了.不少C++的开源项目也已经将标准升级到最新的C++20了,笔者也开启了新标准的学习历程了.所以借这系列的博文,记录下笔者学习新标准的一些心得与吐槽~~ 作为C ...

  7. Elasticsearch-CentOS7单机安装测试

    排版比较丑,但按照此步骤执行一定会搭建成功. 一.环境描述及准备 1.下载Elasticsearch包 curl -L -O https://artifacts.elastic.co/download ...

  8. linux Wireshark图解TCP三次握手与四次挥手

    Linux Wireshark图解TCP三次握手与四次挥手 原文章链接:Wireshark图解TCP三次握手与四次挥手 文章内容丰富 值得学习

  9. tp5 缩略图自写

    1:php终端 安装扩展 使用Composer安装ThinkPHP5的图像处理类库: composer require topthink/think-image2:控制器代码: public func ...

  10. 使用 AHK 在 VS Code 中根据上下文自动切换输入法状态

    平常在VS Code打公式,中英文切换一直狂点 Shift 手都快按断了,于是试图用 AutoHotKey 搞一些自动切换输入法程序,让它根据当前输入环境自动切输入法. 之前在网上搜到的是切换键盘的( ...