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

  • Home
  • SEARCH
  • 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 7046877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:42:10+00:00 2026-05-28T02:42:10+00:00

How can i prevent the sprite image from flickering uncontrollably? (image name is plumbers).

  • 0

How can i prevent the sprite image from flickering uncontrollably? (image name is plumbers). when you run the program the only image flickering is the sprite.

import pygame
import os, sys
import itertools
import pygame
from pygame.sprite import Sprite

cloud_background = pygame.image.load('clouds.bmp')
brick_tile = pygame.image.load('brick_tile.png')
plumbers = pygame.image.load('Mario_sideways_sprite_2xL.png')

pink = (255, 64, 64)
w = 640
h = 480
screen = pygame.display.set_mode((w, h))
running = 1

def setup_background():
    screen.fill((pink))
    screen.blit(cloud_background,(0,0))
    brick_width, brick_height = brick_tile.get_width(), brick_tile.get_height()
    for x,y in itertools.product(range(0,640,brick_width),
                                 range(390,480,brick_height)):
        # print(x,y)
        screen.blit(brick_tile, (x,y))


def show_sprites():
    screen.blit(plumbers,(50,337))
    pygame.display.flip()



while running:
    show_sprites()
    setup_background()
    pygame.display.flip()
    event = pygame.event.poll()
    if event.type == pygame.QUIT: sys.exit()
  • 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-05-28T02:42:11+00:00Added an answer on May 28, 2026 at 2:42 am

    I don’t really know pygame, but whilst you wait for answer from someone with more experience in this area. I can offer this advice which might help.

    Your setting up the background from scratch each time which is a processor intensive process. The best approach is to instead actually only re-render the part of the background required. I.e the parts where your plumber sprite occupied before.

    Normally you do this by creating two variables called old X, old Y. This the rendering process is spend up.

    Currently your render the entire screen every loop cycle.

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

Sidebar

Related Questions

How can I prevent the user from being able to resize an image in
How can I prevent the image tag that calls the associated image from displaying
Is there anyway I can prevent the input type=image from sending the mouse coordinates
Does anyone know how I can prevent the text in a table cell from
How can I prevent a user from resizing GridViewColumns withing a ListView control?
How can I prevent Google and other search engines from indexing my website?
How can I prevent my bitmap from being scaled automatically in an ImageView or
How can I prevent a user from tabbing into a field (comboxbox)?
How can I prevent my javascript from Firebug view?So that I can prevent Hacking
Is there a way that I can prevent a user from logging into a

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.