hazm4t
hazm4t

Reputation: 13

Pygame closes despite while loop

When I run pygame the window opens for a fraction of a second and then immediately closes. I followed multiple tutorials and followed them word for word but the problem still continues.

import pygame

pygame.init()

(width, height) = (300, 300)
window = pygame.display.set_mode((width,height))

run = True
while run:
    window.fill(255,255,200)
    
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False



pygame.quit()

The window doesn't fill either so it feels like the while loop never runs in the first place.

Upvotes: 1

Views: 45

Answers (1)

Rabbid76
Rabbid76

Reputation: 210878

The argument of fill needs to be a tuple with 3 components, instead of 3 separate arguments:

window.fill(255,255,200)

window.fill( (255, 255, 200) )

Upvotes: 2

Related Questions