小编use*_*728的帖子

Python pygame窗口不断崩溃

每当我运行我的代码时,显示的Python窗口都不会响应.
我的代码有问题还是我必须重新安装pygame和python?
我得到一个黑色的pygame窗口,然后它变成白色,说不响应?
我也是新手,所以请尽可能简单.我试着到处寻找答案,但无法以我能理解的方式得到答案.
请帮帮我.谢谢 :)

1 - 导入库

import pygame
from pygame.locals import *
Run Code Online (Sandbox Code Playgroud)

2 - 初始化游戏

pygame.init()
width, height = 640, 480
screen=pygame.display.set_mode((width, height))
Run Code Online (Sandbox Code Playgroud)

3 - 加载图像

player = pygame.images.load("resources/images/dude.png")
Run Code Online (Sandbox Code Playgroud)

4 - 保持循环

while 1:
    # 5 - clear the screen before drawing it again
    screen.fill(0)
    # 6 - draw the screen elements
    screen.blit(player, (100,100))
    # 7 - update the screen
    pygame.display.flip()
    # 8 - loop through the events
    for event in pygame.event.get():
        # check if the event …
Run Code Online (Sandbox Code Playgroud)

python crash pygame

5
推荐指数
1
解决办法
7550
查看次数

标签 统计

crash ×1

pygame ×1

python ×1