[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Surfaces just not blitting



Gregory Piñero wrote:
> Hi guys,
> 
> I'm trying to make a background in pygame.  I want to have it contain
> 3 squares each with a smaller square on it, and then text on the
> smaller square.  Here is the code I wrote, it's short.
> 
> http://www.blendedtechnologies.com/wp-content/MakeABackGround.zip
> 
> For some reason only the first square shows up how I want.  I've been
> staring at the code for an hour trying to figure this out, so now I'm
> hoping one of you experts will have some ideas?
> 
> Thanks in advance,
> 
> Greg

The problem isn't in the numerical order that you draw the GameSpaces, but in
how you draw them. The particular interaction causing the problem is these lines:

GameSpace.__init__:
        self.rect=self.image.get_rect()
        self.rect.top=top
        self.rect.left=left

        if pygame.font:
            font = pygame.font.Font(None, 14)
            text = font.render(name, 1, (10, 10, 10))
            self.header.blit(text, self.rect)
        self.image.blit(self.header, self.rect)

When you call this function with top=200, left=200, self.rect resembles
something along the lines of [200, 200, 100, 100]. When you blit things onto
self.image or self.header, you chose to blit them starting at 200, 200, which is
too far off the surface. This means that they won't get blitted.

Ethan

Attachment: signature.asc
Description: OpenPGP digital signature