my screen is flickering when i move on the x axis and not on the y is there a fix for it this is just a simple piece of code that i wrote so i could show u what my problem is btw i am not shure if this is an issue with my computer or just an issue in my code
import pygame,sys
screen_width = 800
screen_height = 800
screen_halfs = [screen_width//2,screen_height//2]
screen = pygame.display.set_mode((screen_width,screen_height))
clock = pygame.time.Clock()
fps = 40
posx = 100
posy = 100
while True:
mousepos = pygame.mouse.get_pos()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
keys = pygame.key.get_pressed()
if keys[pygame.K_RIGHT]:
posx += 10
if keys[pygame.K_LEFT]:
posx -= 10
if keys[pygame.K_UP]:
posy -= 10
if keys[pygame.K_DOWN]:
posy += 10
screen.fill((255,255,255))
pygame.draw.rect(screen,(255,0,0),(posx,posy,50,50))
pygame.display.flip()
clock.tick(fps)