I was trying to make a Pygame game, and when I went to the player movement, the player duplicates.
Here is the code:
#import libraries
import pygame
import sys
#variables
width = 850
height = 850
player_movement = 425
pygame.init()
screen = pygame.display.set_mode((width, height))
clock = pygame.time.Clock()
pygame.display.set_caption("Prokect!")
player = pygame.transform.scale2x(pygame.image.load("player.png"))
#main loop
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
player_movement -= 5
if event.key == pygame.K_DOWN:
player_movement += 5
screen.blit(player, (10, player_movement))
pygame.display.update()
clock.tick(60)
The question is, why does the player duplicate when the sprite (player) is moving?