[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Re: overlayed text
> > your problem here is that your are blitting the text _after_ you
> > update the display. swap those last two lines around.
>
> i put in the update _after_ it didnt work 6 times ;)
hmm, well perhaps try to determine where your code differs from my
little attached example? hopefully this helps.
"""example of text on white"""
message = "Press any key to exit."
textcolor = 200, 0, 0
backcolor = 255, 255, 255
import pygame
import pygame.font
from pygame.locals import *
def main():
pygame.init()
screen = pygame.display.set_mode((640, 480))
tophalf = screen.get_rect()
tophalf.height = tophalf.centery
screen.fill(backcolor, tophalf)
font = pygame.font.Font(None, 40)
text = font.render(message, 1, textcolor)
screen.blit(text, (40, 40))
pygame.display.flip()
while pygame.event.wait().type not in (QUIT, KEYDOWN): pass
if __name__ == '__main__': main()