-1
I am doing some tests in pygame and created a "character" that moves, but it creates a ghost effect on the screen. I’d like to know how to solve.
(This land is what the character would be)
The phantom effect I refer to is that when moving, the character "walks", but may create a "copy" of it (as shown in the image)
The code I’ll put on the moving part:
class playerA(pygame.sprite.Sprite):
velocidade = 20
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.ImagemPlayer = pygame.image.load("dirt.png")
self.rect = self.ImagemPlayer.get_rect()
self.rect.centerx = largura / 2
self.rect.centery = altura - 60
def colocar(self,sup):
sup.blit(self.ImagemPlayer, self.rect)
def main():
while sair != True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sair = True
if(event.type == pygame.KEYDOWN):
if event.key == pygame.K_LEFT :
player.rect.left -= player.velocidade
elif event.key == pygame.K_RIGHT :
player.rect.right += player.velocidade
elif event.key == pygame.K_UP :
player.rect.top -= player.velocidade
elif event.key == pygame.K_DOWN :
player.rect.top += player.velocidade