[英]Python -> Pygame Window Close instatly
我正在學習 Clear Code 教程,我的 pygame window 立即關閉,我看到有些人在談論身份驗證,但我認為沒關系。
import pygame, sys
from settings import *
class Game:
def __init__(self):
# General Setup
pygame.init()
self.screen = pygame.display.set_mode((LARGURA, ALTURA))
pygame.display.set_caption('Pozzani Rugby Game')
self.clock = pygame.time.Clock()
def run(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
self.screen.fill('black')
pygame.display.update()
self.clock.tick(FPS)
if __name__ == '__main__':
game = Game()
game.run
你需要調用 run function 就像game.run()
,如果你只說game.run
就像只是提到 function 而不是調用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.