为了账号安全,请及时绑定邮箱和手机立即绑定

pygame窗口永远加载

pygame窗口永远加载

Smart猫小萌 2022-07-19 20:31:29
我是 pygame 的新手,我只是想用它编写国际象棋代码,但是我在后台加载时遇到了麻烦我查阅了很多教程,我认为一切都很好,我在做什么花了这么多时间?import pygame pygame.init#create the screen with 800 pixals width and 600 pixals hieghtscreen = pygame.display.set_mode((800,600))# Backgroundbackground = pygame.image.load("chessboard.png")running = Truewhile running:    #RGB colors    screen.fill((234,0,0))    #background image    screen.blit(background,(0,0))    for event in pygame.event.get():        if event.type == pygame.QUIT:            running = Falsepygame.quit()
查看完整描述

1 回答

?
RISEBY

TA贡献1856条经验 获得超5个赞

首先pygame.init是没有函数调用。这个声明根本没有任何作用。您必须添加括号来调用init():


pygame.init()

此外,您错过了pygame.display.flip()在主应用程序循环中更新显示():


running = True

while running:


    for event in pygame.event.get():

        if event.type == pygame.QUIT:

            running = False


    #RGB colors

    screen.fill((234,0,0))

    #background image

    screen.blit(background,(0,0))


    # update display

    pygame.display.flip()


查看完整回答
反对 回复 2022-07-19
  • 1 回答
  • 0 关注
  • 112 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号