0
votes

no idea what's wrong

won't let me post the full code, searched this website and google, but found no answers...

DISPLAYSURF=pygame.display.set_mode((width,height),0,32)

sprite=pygame.image.load('generic_legionnary.png'

def move(direction, sprite, spritex, spritey):
    if direction:
        if direction == K_UP:
            spritey-=5
            sprite=pygame.image.load('generic_legionnary.png')
        elif direction == K_DOWN:
            spritey+=5
            sprite=pygame.image.load('generic_legionnary.png')
        if direction == K_LEFT:
            spritex-=5
            sprite=pygame.image.load('generic_legionnary.png')
        elif direction == K_RIGHT:
            spritex+=5
            sprite=pygame.image.load('generic_legionnary.png')
    return sprite, spritex, spritey

while True:

    DISPLAYSURF.blit(sprite,(spritex,spritey))

I don't know what's wrong, it keeps putting new images when moving, how can I make sure that it's only one drawing that's moving? thanks!

Edit: solved it

screen.fill((255,255,255))

sets the background color and the tracing thing disappears

1

1 Answers

0
votes

Do you clear your screen at the start of each loop ?

Why are you loading new sprites each time you move ?

Who need only the one loaded before the function, not the others.

If you don't clear your screen in each loop, you get this trace. (or your trace might be the old sprites that you have overwritten, but normally the garbage collector should get rid of them.)