import pygame
import os
import time
import random
pygame.init()
win = pygame.display.set_mode((500,500))
bg_img = pygame.image.load('Downloads/map_image.png')
bg_img = pygame.transform.scale(bg_img,(500,500))
pygame.display.set_caption("Game")
screenWidth = 500
#values
x = 50
y = 425
width = 40
height = 60
vel = 5
#main loop
run = True
while run:
win.blit(bg_img,(0,0))
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
#keys
keys = pygame.key.get_pressed()
if keys[pygame.K_a] and x > vel:
x -= vel
if keys[pygame.K_d] and x < 530 - width - vel:
x += vel
if keys[pygame.K_LEFT] and x > vel:
x -= vel
if keys[pygame.K_RIGHT] and x < 530 - width - vel:
x += vel
if keys[pygame.K_w] and y > vel:
y -= vel
if keys[pygame.K_s] and y < 530 - width - vel:
y += vel
if keys[pygame.K_UP] and y > vel:
y -= vel
if keys[pygame.K_DOWN] and y < 530 - width - vel:
y += vel
win.fill((0,0,0))
#character
pygame.draw.circle(win, (11,3,252), (x, y), 14)
pygame.time.delay(0)
pygame.display.update()
pygame.quit()
I have tried increasing the time delay, but it still flickers. Please help me fix it so it will be a constant image and so my circle character is visible on the image. The problem arose once I put the image in, but then it would flicker a lot. Now it flickers not as much, but it still flickers very often. If I try to take out the first pygame.display.update() the background image doesn't even load (with a pygame.display.update() at the end of the code).