Vinicius Pozzani
Vinicius Pozzani

Reputation: 3

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.

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

Upvotes: 0

Views: 47

Answers (1)

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.

Upvotes: 1

Related Questions