pygame | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1


How can i place some lines or words in window in pygame?

13th Jan 2020, 4:06 PM
Hacker Lacker
Hacker Lacker - avatar
1 Answer
+ 3
You can use pygame.font module. #First you need to make font (this don't need to be repeated): font = pygame.font.Font(None, <font_size>) This is needed to be done once per text: text_surface = font.render(<text string>, 1, <color (R, G, B)> text_rect = text_surface.get_rect() And this is repeated each time you want to draw the text on surface: surface.blit(text_surface, text_rect) You can move the text by: text_rect.move_ip(<xpos>, <ypos>)
13th Jan 2020, 4:35 PM
Seb TheS
Seb TheS - avatar