I am trying to make a game with pygame, but whenever I run my game, nothing shows up until I close the window, then stuff appears for a second. I don't know what is going on but I think is has to do with my display.update. Here is my code:
import pygame
import colorama
import math
import random #All needed libraries
import time
import os
from colorama import init, Fore, Back, Style #All needed extras
from pygame.locals import (
K_UP,
K_DOWN,
K_LEFT,
K_RIGHT,
K_ESCAPE,
KEYDOWN,
QUIT,
)
init()
pygame.init()
SCREEN_WIDTH = 400
SCREEN_HEIGHT = 400
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
running = True
while running:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False
elif event.type == QUIT:
running = False
screen.fill((255, 255, 255))
surf = pygame.Surface((50, 50))
surf.fill((0, 0, 0))
rect = surf.get_rect()
screen.blit(surf, (SCREEN_WIDTH/2, SCREEN_HEIGHT/2))
rect.update()
pygame.display.update()
why isn't it working?