Skip to content
Advertisement

Python3 PyGame how to move an image?

I tried to use .blit but an issue occurs, here is a screenshot to explain my problem furthermore:

The image appears to be smudged across the screen following my mouse

It just copies my image.

code:

JavaScript

Advertisement

Answer

Fix the indentation in your given code, it puts all the important stuff outside the while loop. You can also add a function that redraws the window each time the sprite is moved:

JavaScript

And put this at the end of your program, after putting all fill and blit statements inside the function:

JavaScript

This function will make it easier for you to blit more items on the screen, and this will prevent the object from drawing on the screen, because the screen is updated every time the object is moved.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement