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

源代码

  1. 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


  1. 原因在于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. (一) operator、explicit与implicit 操作符重载

                               原文地址:  Click Here 操作符重载必须用public static 应为操作符是用来操作实例的. operator operator ...

  2. c++刷leetcode记录

    #include<iostream> #include<sstream> #include<vector> std::vector<int> split ...

  3. oauth2.0密码模式详解

    oauth2.0密码模式 欢迎关注博主公众号「Java大师」, 专注于分享Java领域干货文章http://www.javaman.cn/sb2/oauth-password 如果你高度信任某个应用, ...

  4. 被vector动态扩容给坑了!

    大家好,我是东北码农.记录一下工作中事. 前几天,运维同事给我反馈了一个问题: 通过监控发现,线上的一个服务,业务线程时不时会出现卡顿,卡顿大约持续几秒. 我们做金融系统后台开发的,对性能要求很严格的 ...

  5. Applied-Social-Network-Analysis-in-Python 相关笔记4

    模型数据越多,Average系数就越小. perferential attachment model 有比较小的平均路径长度,但有着小的cc. rewire:重新连接 如果仅看这个共同的邻居数的话,数 ...

  6. CentOS8安装Geant4笔记(三):Geant4介绍、编译、安装支持Qt5界面并运行exampleB1例程显示Qt界面

    前言   上一篇,安装了Qt5环境.  本篇在服务器CentOs8.2上安装geant4软件,geant4使用Qt5来显示.   GEANT4 介绍   Geant4 是一个用于模拟粒子穿过物质的工具 ...

  7. 最详尽教程完整介绍-Windows 的 Linux 子系统-WSL1&WSL2

    安装 WSL 1. 开启WSL 必须启用"适用于 Linux 的 Windows 子系统"可选功能并重启,然后才能在 Windows 上运行 Linux 发行版. 以管理员运行Po ...

  8. TypeScript方法的定义

    在 JavaScript 中,有两种方式定义方法. 1.命名的方法 function add(x,y){ return x+y;}2.匿名方法 var myAdd = function(x,y) { ...

  9. Python:用pyinstrument做性能分析

    导引 在计算密集型计算或一些Web应用中,我们常常需要对代码做性能分析.在Python中,最原始的方法即是使用time包中的time函数(该函数以秒为计时单位): from time import s ...

  10. JavaWeb Bug处理

    1.(getParameter) Java文本无法解析Cannot resolve method 'getParameter(java.lang.String)方法    解决方法:1.在projec ...