Paul Brown
Paul Brown

Reputation: 53

Pygame TypeError: argument 1 must be > pygame.Surface, not pygame.Rect

I am making a helpscreen for my pygame and I keep getting this error message whenever I run it:

> self.surface.blit(self.helpscreen) TypeError: argument 1 must be
> pygame.Surface, not pygame.Rect

I don't know how to fix it and I am still learning pygame so I need a pretty basic answer if possible. My code is below:

def help(self):

    pygame.init()
    self.FPS = 60
    self.fps_clock = pygame.time.Clock()
    self.surface = pygame.display.set_mode((640, 480))
    helpscreen = DISPLAY_SURF.fill(white)
    self.surface.blit(helpscreen)
    # This class sets the basic attributes for the window.
    # The clock is set to 60 and the name of the window
    # is set to The Hunt which is a working title for my project
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
    while True:
        pygame.display.update()
        self.fps_clock.tick(self.FPS)
        self.process_game()

Upvotes: 1

Views: 52

Answers (1)

skrx
skrx

Reputation: 20438

Either just fill the display surface self.surface.fill(white) or create a background surface and blit it on the self.surface:

helpscreen = pygame.Surface(self.surface.get_size())
helpscreen.fill(white)
self.surface.blit(helpscreen, (0, 0))

Upvotes: 1

Related Questions