pygame Surface.fill doesn't work (at all)

Viewed 30

I was trying to create a small ping-pong game with python and pygame, but I run into a huge problem: it doesnt work. My code opens a window, but doesn't fill it. I've tried different variants of solving, but nothing seems to help. And I tried to compile this code in online compiler (Replit), but it doesn'tseem to work there neither.

import pygame

#screen initializing
WIDTH, HEIGHT = 900, 500
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('Ping-Pong')

for i in range(1000):
 screen.fill((200, 200, 200))

this code just opens a black window, no matter what number I write in. What can cause fill() function to not work?

1 Answers

Add pygame.display.update() at the end to update the screen

Related