0

I want to blit out my image on the screen with Pygame, but it doesn't work; It gives me a warning :

Cannot find reference 'load' in 'image.py'

And during execution time, it gives no such fatal error. All I get is a blank white screen with no image. I have referred to this and this, but just does not seem to work. This is my code:

import pygame

class Bouncer(object):

    display_width = 600
    display_height = 400
    color_white = (255, 255, 255)
    clock = pygame.time.Clock()
    game_exit = False
    bar_image = pygame.image.load('bar.png') # <------ here is the issue

    def __init__(self):

        pygame.init()
        self.game_display = pygame.display.set_mode((self.display_width, 
        self.display_height))
        pygame.display.set_caption('Bouncy Bouncer')


    def showBar(self):

        self.game_display.blit(self.bar_image, (10, 10))


    def gameLoop(self):

        while not self.game_exit:

            for event in pygame.event.get():

                #on close quit
                if event.type == pygame.QUIT:

                        self.game_exit = True
                        pygame.quit()
                        quit()

                #on key press quit
                if event.type == pygame.KEYDOWN:

                    if event.key == pygame.K_x:

                        self.game_exit = True
                        pygame.quit()
                        quit()

            self.showBar()

            self.game_display.fill(self.color_white)
            pygame.display.update()
            self.clock.tick(60)


game_instance = Bouncer()
game_instance.gameLoop()
Irfan Sindhi
  • 75
  • 1
  • 8

1 Answers1

0

I called fiest called my image then the fill function, so it overlapped the white background, thus, covering the image. So, what I did was first call the background, then the image.

Irfan Sindhi
  • 75
  • 1
  • 8