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

Re: [pygame] beginner problem.



Hi Elvelind.

background is just a Surface (an image).  It gets drawn on the screen when
you call screen.blit().

afterward, you draw "pummel" onto the Surface, but you don't draw that
onto the screen again, so it still looks the same.

you should do screen.blit() after you draw "pummel" onto the Surface named
"background".

-sjbrown


> Hi. im trying to get started with pygame but have runned in to some
> problem.
>
> the cobe below will show a window with a bg but not the text. what am
> I doing wrong?
>
> import pygame ,sys
> from pygame.locals import *
> if not pygame.font: print 'Warning, fonts disabled'
> if not pygame.mixer: print 'Warning, sound disabled'
>
> pygame.init()
> screen = pygame.display.set_mode((468, 60))
> pygame.display.set_caption('Monkey Fever')
> pygame.mouse.set_visible(1)
>
> background = pygame.Surface(screen.get_size())
> background = background.convert()
> background.fill((130, 120, 210))
> screen.blit(background, (0, 0))
>
> font = pygame.font.SysFont("fixed", 20)
> text = font.render("Pummel", 0, (100, 100, 100))
> background.blit(text,(0,0) )
>
> while 1:
>         pygame.display.flip()
>
>
>
> cheers
> elvelind
>


----
Sent from geeky.net