Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:26:54+00:00 2026-06-14T11:26:54+00:00

When I move an image around my PyGame screen, if it happens to pass

  • 0

When I move an image around my PyGame screen, if it happens to pass over another image, those onderneath get hidden and cannot be seen again. Why might this be?

My code is:

def main():
    screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

    background = pygame.image.load('Background.png').convert()
    screen.blit(background, (0, 0))  # draw the background screen

    human1 = pygame.image.load('Human1.gif').convert()
    human1_position = pygame.Rect(10, BOTTOM_FLOOR, CHARACTER_WIDTH, CHARACTER_HEIGHT)
    screen.blit(human1, human1_position)  # draw the first human

    human2 = pygame.image.load('Human2.gif').convert()
    human2_position = pygame.Rect(100, BOTTOM_FLOOR, CHARACTER_WIDTH, CHARACTER_HEIGHT)
    screen.blit(human2, human2_position)  # draw the second human

    human3 = pygame.image.load('Human3.gif').convert()
    human3_position = pygame.Rect(190, BOTTOM_FLOOR, CHARACTER_WIDTH, CHARACTER_HEIGHT)
    screen.blit(human3, human3_position)  # draw the third human

    pygame.display.update()  # display all graphical elements

    move = STOP  # Variable to track what the current move is. Initially, stopped
    move_character = 1  # Variable to track which character is being moved

    while True:
        #
        # See what the user did...
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            elif event.type == pygame.KEYDOWN:

                # Check if there is a move currently happening. The program
                # will only do something if the previous move is stopped
                if move == STOP:
                    # Check which key was pressed...
                    if event.key == pygame.K_1:
                        # if key pressed is the '1' key, move first human (and check if moving from bottom to top or other way)
                        move_character = 1  # the first character is to be moved
                        if human1_position.top < 300:
                            # If the 'top' of the human's position is less 
                            # than 300 then it means the human is currenlty
                            # on the top half of the screen, and so
                            # the next move will be to move it downards
                            move = DOWN
                        else:
                            move = UP

                    # Check which key was pressed...
                    if event.key == pygame.K_2:
                        # if key pressed is the '2' key, move second human (and check if moving from bottom to top or other way)
                        move_character = 2 # the first character is to be moved
                        if human2_position.top < 300:
                            # If the 'top' of the human's position is less 
                            # than 300 then it means the human is currenlty
                            # on the top half of the screen, and so
                            # the next move will be to move it downards
                            move = DOWN
                        else:
                            move = UP

            screen.blit(background, human1_position, human1_position) # erase old position of first human
            if (move == UP):
                #they want to move up, so first check the lift is down with them.
                if (liftLoc == "down"):
                    #they are both down, they can be moved into the lift
                    if (human1_position.left <= 245):
                        human1_position = human1_position.move(2, 0)  # move first human
                        pygame.display.update()
                    else:
                        move = STOP
                else:
                    print "Wrong floor!"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:26:56+00:00Added an answer on June 14, 2026 at 11:26 am

    So the problem you are having, is that you are only rendering/blitting the images you move over when you start, so they get “unrendered” or rendered over.
    To get rid of this problem, like all other real time rendering engines, you should render everything you want someone to see, every frame you want something to happen.

    I shall not give you the code correction, but just moving the screen.blit of every image into your while loop. Their position will obviously affect the rendering order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this image in Pygame which moves around the screen. What I want
im trying to get a sprite to move around the screen with a walk
I want to move an image around the screen according to the trackball movement.
I am currently trying to have an image move around the screen in certain
I have created Pygame, which has objects (balls) which randomly move around the screen
I'm trying to animate an image using KineticJS to move across the screen, but
I'm using a pan gesture to move around an image. You touch down, drag,
I'm trying to get a bunch of div's to wrap around an image, but
I have an image view that I want to be able to move around,
It's simple enough to define an image in xaml and move it around, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.