亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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 關注
  • 111 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號