pygame窗口永远加载

我是 pygame 的新手,我只是想用它编写国际象棋代码,但是我在后台加载时遇到了麻烦我查阅了很多教程,我认为一切都很好,我在做什么花了这么多时间?


import pygame 


pygame.init


#create the screen with 800 pixals width and 600 pixals hieght

screen = pygame.display.set_mode((800,600))


# Background

background = pygame.image.load("chessboard.png")




running = True

while 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 = False



pygame.quit()


Smart猫小萌
浏览 113回答 1
1回答

RISEBY

首先pygame.init是没有函数调用。这个声明根本没有任何作用。您必须添加括号来调用init():pygame.init()此外,您错过了pygame.display.flip()在主应用程序循环中更新显示():running = Truewhile 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()
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python