Skip to content Skip to sidebar Skip to footer

Not Able To Move Image In Pygame

I am a beginner in Python. I am trying to shift image using pygame module. But I am not able to shift position of the image in python. Can you help me understand what I am doing wr

Solution 1:

A basic game loop should do three things: handle events, update and draw. I see the logic where you update the position of the rectangle, but you don't redraw the image at the new position.

I've added lines at the bottom of the game loop to draw the scene.

whileTrue: 
    # handle events# update logic# draw
    Canvas.fill((0, 0, 0))  # Clears the previous image.
    Canvas.blit(image, imgrect)  # Draws the image at the new position.
    pygame.display.update()  # Updates the screen.

Post a Comment for "Not Able To Move Image In Pygame"