[英]Python -> Pygame Window Close instatly
i'm follow Clear Code tutorial, and my pygame window closes instantly, i see some guys talking about identation, but i think that's ok.我正在学习 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
you need to call the run function like game.run()
, if you only say game.run
is like just mentioning the function but not invoking it.你需要调用 run function 就像
game.run()
,如果你只说game.run
就像只是提到 function 而不是调用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.